]> granicus.if.org Git - python/commitdiff
Set cache sizes to a power-of-two
authorRaymond Hettinger <python@rcn.com>
Sun, 17 Feb 2013 09:33:37 +0000 (01:33 -0800)
committerRaymond Hettinger <python@rcn.com>
Sun, 17 Feb 2013 09:33:37 +0000 (01:33 -0800)
Lib/fnmatch.py
Lib/re.py

index f446769b9f6661129798917ceb7b184cc2668738..6330b0cfdab5daf1eda2882c3b3eeb8afd6dff70 100644 (file)
@@ -35,7 +35,7 @@ def fnmatch(name, pat):
     pat = os.path.normcase(pat)
     return fnmatchcase(name, pat)
 
-@functools.lru_cache(maxsize=250, typed=True)
+@functools.lru_cache(maxsize=256, typed=True)
 def _compile_pattern(pat):
     if isinstance(pat, bytes):
         pat_str = str(pat, 'ISO-8859-1')
index 9ae51740e4ae3f82f4f3efe9e288f49e36e483d4..952b60f45bfe8390152c392f7f844df538f9a491 100644 (file)
--- a/Lib/re.py
+++ b/Lib/re.py
@@ -261,7 +261,7 @@ def escape(pattern):
 
 _pattern_type = type(sre_compile.compile("", 0))
 
-@functools.lru_cache(maxsize=500, typed=True)
+@functools.lru_cache(maxsize=512, typed=True)
 def _compile(pattern, flags):
     # internal: compile pattern
     if isinstance(pattern, _pattern_type):
@@ -273,7 +273,7 @@ def _compile(pattern, flags):
         raise TypeError("first argument must be string or compiled pattern")
     return sre_compile.compile(pattern, flags)
 
-@functools.lru_cache(maxsize=500)
+@functools.lru_cache(maxsize=512)
 def _compile_repl(repl, pattern):
     # internal: compile replacement pattern
     return sre_parse.parse_template(repl, pattern)