Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Lib/re/_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,11 @@ def _optimize_charset(charset, iscased=None, fixup=None, fixes=None):
if not hascased:
hascased = any(map(iscased, r))
else:
for i in r:
charmap[i] = 1
end = av[1] + 1
if end > len(charmap):
# Trigger the IndexError growth path below.
raise IndexError
charmap[av[0]:end] = b'\x01' * (end - av[0])
elif op is NEGATE:
out.append((op, av))
elif op is CATEGORY and tail and (CATEGORY, CH_NEGATE[av]) in tail:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Speed up :func:`re.compile` of patterns with character ranges by replacing
the per-byte loop in :mod:`!re._compiler` with a single bytearray slice
fill.
Loading