diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-11-07 23:42:46 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-11-07 23:42:46 (GMT) |
commit | 1ec1cd161b351bc42c4b55c0f943fa5f8fe1bb6e (patch) | |
tree | 1fa9fac0f32efc99837a3946bb5301b4da91adc7 | |
parent | 9b88fdf4f09b77d866a3591c9e64b4e8a5b25920 (diff) | |
download | cpython-1ec1cd161b351bc42c4b55c0f943fa5f8fe1bb6e.zip cpython-1ec1cd161b351bc42c4b55c0f943fa5f8fe1bb6e.tar.gz cpython-1ec1cd161b351bc42c4b55c0f943fa5f8fe1bb6e.tar.bz2 |
Issue #28637: Revert issue #28082, don't import enum in re
Importing the enum module in the re module slows down Python startup by 34%
when Python is run from a virtual environment, or more generally when the re
module is imported at startup but not the enum module.
-rw-r--r-- | Lib/re.py | 33 |
1 files changed, 12 insertions, 21 deletions
@@ -119,7 +119,6 @@ This module also defines an exception 'error'. """ -import enum import sre_compile import sre_parse import functools @@ -139,26 +138,18 @@ __all__ = [ __version__ = "2.2.1" -class RegexFlag(enum.IntFlag): - ASCII = sre_compile.SRE_FLAG_ASCII # assume ascii "locale" - IGNORECASE = sre_compile.SRE_FLAG_IGNORECASE # ignore case - LOCALE = sre_compile.SRE_FLAG_LOCALE # assume current 8-bit locale - UNICODE = sre_compile.SRE_FLAG_UNICODE # assume unicode "locale" - MULTILINE = sre_compile.SRE_FLAG_MULTILINE # make anchors look for newline - DOTALL = sre_compile.SRE_FLAG_DOTALL # make dot match newline - VERBOSE = sre_compile.SRE_FLAG_VERBOSE # ignore whitespace and comments - A = ASCII - I = IGNORECASE - L = LOCALE - U = UNICODE - M = MULTILINE - S = DOTALL - X = VERBOSE - # sre extensions (experimental, don't rely on these) - TEMPLATE = sre_compile.SRE_FLAG_TEMPLATE # disable backtracking - T = TEMPLATE - DEBUG = sre_compile.SRE_FLAG_DEBUG # dump pattern after compilation -globals().update(RegexFlag.__members__) +# flags +A = ASCII = sre_compile.SRE_FLAG_ASCII # assume ascii "locale" +I = IGNORECASE = sre_compile.SRE_FLAG_IGNORECASE # ignore case +L = LOCALE = sre_compile.SRE_FLAG_LOCALE # assume current 8-bit locale +U = UNICODE = sre_compile.SRE_FLAG_UNICODE # assume unicode "locale" +M = MULTILINE = sre_compile.SRE_FLAG_MULTILINE # make anchors look for newline +S = DOTALL = sre_compile.SRE_FLAG_DOTALL # make dot match newline +X = VERBOSE = sre_compile.SRE_FLAG_VERBOSE # ignore whitespace and comments + +# sre extensions (experimental, don't rely on these) +T = TEMPLATE = sre_compile.SRE_FLAG_TEMPLATE # disable backtracking +DEBUG = sre_compile.SRE_FLAG_DEBUG # dump pattern after compilation # sre exception error = sre_compile.error |