Skip to content

Commit d0dbb20

Browse files
committed
Set cache sizes to a power-of-two
1 parent 5b49962 commit d0dbb20

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Lib/fnmatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def fnmatch(name, pat):
3535
pat = os.path.normcase(pat)
3636
return fnmatchcase(name, pat)
3737

38-
@functools.lru_cache(maxsize=250, typed=True)
38+
@functools.lru_cache(maxsize=256, typed=True)
3939
def _compile_pattern(pat):
4040
if isinstance(pat, bytes):
4141
pat_str = str(pat, 'ISO-8859-1')

Lib/re.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def escape(pattern):
261261

262262
_pattern_type = type(sre_compile.compile("", 0))
263263

264-
@functools.lru_cache(maxsize=500, typed=True)
264+
@functools.lru_cache(maxsize=512, typed=True)
265265
def _compile(pattern, flags):
266266
# internal: compile pattern
267267
if isinstance(pattern, _pattern_type):
@@ -273,7 +273,7 @@ def _compile(pattern, flags):
273273
raise TypeError("first argument must be string or compiled pattern")
274274
return sre_compile.compile(pattern, flags)
275275

276-
@functools.lru_cache(maxsize=500)
276+
@functools.lru_cache(maxsize=512)
277277
def _compile_repl(repl, pattern):
278278
# internal: compile replacement pattern
279279
return sre_parse.parse_template(repl, pattern)

0 commit comments

Comments
 (0)