Skip to content

Commit

Permalink
change the cache size for re.escape
Browse files Browse the repository at this point in the history
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 glpyhs), we double the cache size.
  • Loading branch information
picnixz committed Aug 28, 2024
1 parent f4eaa10 commit a205e6b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Lib/fnmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def translate(pat):
return _join_translated_parts(parts, indices)

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

def _translate(pat, star, question_mark):
res = []
Expand Down

0 comments on commit a205e6b

Please sign in to comment.