[Python-checkins] cpython: Issue #22510: Get rid of little overhead of testing re.DEBUG flag.
serhiy.storchaka
python-checkins at python.org
Mon Sep 29 17:15:02 CEST 2014
https://hg.python.org/cpython/rev/565096a32ce4
changeset: 92626:565096a32ce4
parent: 92624:3d924bbfdcbc
user: Serhiy Storchaka <storchaka at gmail.com>
date: Mon Sep 29 18:13:02 2014 +0300
summary:
Issue #22510: Get rid of little overhead of testing re.DEBUG flag.
files:
Lib/re.py | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/Lib/re.py b/Lib/re.py
--- a/Lib/re.py
+++ b/Lib/re.py
@@ -273,12 +273,10 @@
_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 @@
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
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list