diff options
author | yannvgn <hi@yannvgn.io> | 2019-07-31 18:50:39 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2019-07-31 18:50:39 (GMT) |
commit | 9f55551f3df238e58315e724e50cb0d574d75b94 (patch) | |
tree | 2f9e1111998e94e0c5b212e4250eeb5bbe13ac02 /Lib/sre_parse.py | |
parent | 1b29af83bc17e773b0c0d117f5fe1018fde46b0d (diff) | |
download | cpython-9f55551f3df238e58315e724e50cb0d574d75b94.zip cpython-9f55551f3df238e58315e724e50cb0d574d75b94.tar.gz cpython-9f55551f3df238e58315e724e50cb0d574d75b94.tar.bz2 |
bpo-37723: Fix performance regression on regular expression parsing. (GH-15030)
Improve performance of sre_parse._uniq function.
Diffstat (limited to 'Lib/sre_parse.py')
-rw-r--r-- | Lib/sre_parse.py | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py index 84c9125..8311916 100644 --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -430,13 +430,7 @@ def _escape(source, escape, state): raise source.error("bad escape %s" % escape, len(escape)) def _uniq(items): - if len(set(items)) == len(items): - return items - newitems = [] - for item in items: - if item not in newitems: - newitems.append(item) - return newitems + return list(dict.fromkeys(items)) def _parse_sub(source, state, verbose, nested): # parse an alternation: a|b|c |