8000 change the cache size for `re.escape` · python/cpython@bb6c3ee · GitHub
[go: up one dir, main page]

Skip to content

Commit bb6c3ee

Browse files
committed
change the cache size for re.escape
The rationale for this change is as follows: re.escape() is only used to cache single Unicode characters in shell patterns; we may heuristically assume that they are ISO-8859-1 encodable, thereby requiring a cache of size 256. To allow non-traditional glyphs (or alphabets with a small number of common glyphs), we double the cache size.
1 parent 01a5173 commit bb6c3ee

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Lib/fnmatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def translate(pat):
8181
return _join_translated_parts(parts, indices)
8282

8383
_re_setops_sub = re.compile(r'([&~|])').sub
84-
_re_escape = functools.lru_cache(maxsize=32768)(re.escape)
84+
_re_escape = functools.lru_cache(maxsize=512)(re.escape)
8585

8686
def _translate(pat, star, question_mark):
8787
res = []

0 commit comments

Comments
 (0)
0