Skip to content

Commit c2a0b52

Browse files
committed
gh-141968: Use take_byes in re._compiler
Removes a copy going from bytearray to bytes.
1 parent bc9e63d commit c2a0b52

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Lib/re/_compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def _optimize_charset(charset, iscased=None, fixup=None, fixes=None):
375375
# less significant byte is a bit index in the chunk (just like the
376376
# CHARSET matching).
377377

378-
charmap = bytes(charmap) # should be hashable
378+
charmap = charmap.take_bytes() # should be hashable
379379
comps = {}
380380
mapping = bytearray(256)
381381
block = 0
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Remove data copy from :mod:`re` compilation of regexes with large charsets
2+
by using :func:`bytearray.take_byes`.

0 commit comments

Comments
 (0)