summaryrefslogtreecommitdiffstats
path: root/Lib/re.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-09-29 15:13:02 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-09-29 15:13:02 (GMT)
commit4d75a01798cf0ff112335804382bd4bf50f7bf78 (patch)
tree197aee86b3a15b3c35a3becc63c152f6ca09fb17 /Lib/re.py
parentd034ece5b3150be8ba5d48d79b45379ec767cfa3 (diff)
downloadcpython-4d75a01798cf0ff112335804382bd4bf50f7bf78.zip
cpython-4d75a01798cf0ff112335804382bd4bf50f7bf78.tar.gz
cpython-4d75a01798cf0ff112335804382bd4bf50f7bf78.tar.bz2
Issue #22510: Get rid of little overhead of testing re.DEBUG flag.
Diffstat (limited to 'Lib/re.py')
-rw-r--r--Lib/re.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/Lib/re.py b/Lib/re.py
index 2a410c8..8f5b399 100644
--- a/Lib/re.py
+++ b/Lib/re.py
@@ -273,12 +273,10 @@ _pattern_type = type(sre_compile.compile("", 0))
_MAXCACHE = 512
def _compile(pattern, flags):
# internal: compile pattern
- bypass_cache = flags & DEBUG
- if not bypass_cache:
- try:
- return _cache[type(pattern), pattern, flags]
- except KeyError:
- pass
+ try:
+ return _cache[type(pattern), pattern, flags]
+ except KeyError:
+ pass
if isinstance(pattern, _pattern_type):
if flags:
raise ValueError(
@@ -287,7 +285,7 @@ def _compile(pattern, flags):
if not sre_compile.isstring(pattern):
raise TypeError("first argument must be string or compiled pattern")
p = sre_compile.compile(pattern, flags)
- if not bypass_cache:
+ if not (flags & DEBUG):
if len(_cache) >= _MAXCACHE:
_cache.clear()
_cache[type(pattern), pattern, flags] = p