summaryrefslogtreecommitdiffstats
path: root/Lib/re.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-10-20 15:57:45 (GMT)
committerRaymond Hettinger <python@rcn.com>2011-10-20 15:57:45 (GMT)
commitcd9fdfd652cdaca959b1c5d4cddf60d90a331b47 (patch)
treef714220e35080ef6ad49bc0a88999483fcb0e14a /Lib/re.py
parente3455c026afdf5d4448aefde44f7530ea456a9e0 (diff)
downloadcpython-cd9fdfd652cdaca959b1c5d4cddf60d90a331b47.zip
cpython-cd9fdfd652cdaca959b1c5d4cddf60d90a331b47.tar.gz
cpython-cd9fdfd652cdaca959b1c5d4cddf60d90a331b47.tar.bz2
Issue 13227: Option to make the lru_cache() type specific (suggested by Andrew Koenig).
Diffstat (limited to 'Lib/re.py')
-rw-r--r--Lib/re.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/Lib/re.py b/Lib/re.py
index cdf5976..4b90b3f 100644
--- a/Lib/re.py
+++ b/Lib/re.py
@@ -207,7 +207,7 @@ def compile(pattern, flags=0):
def purge():
"Clear the regular expression caches"
- _compile_typed.cache_clear()
+ _compile.cache_clear()
_compile_repl.cache_clear()
def template(pattern, flags=0):
@@ -253,11 +253,8 @@ def escape(pattern):
_pattern_type = type(sre_compile.compile("", 0))
+@functools.lru_cache(maxsize=500, typed=True)
def _compile(pattern, flags):
- return _compile_typed(type(pattern), pattern, flags)
-
-@functools.lru_cache(maxsize=500)
-def _compile_typed(text_bytes_type, pattern, flags):
# internal: compile pattern
if isinstance(pattern, _pattern_type):
if flags: