Commit 9f55551f authored by yannvgn's avatar yannvgn Committed by Serhiy Storchaka

bpo-37723: Fix performance regression on regular expression parsing. (GH-15030)

Improve performance of sre_parse._uniq function.
parent 1b29af83
...@@ -430,13 +430,7 @@ def _escape(source, escape, state): ...@@ -430,13 +430,7 @@ def _escape(source, escape, state):
raise source.error("bad escape %s" % escape, len(escape)) raise source.error("bad escape %s" % escape, len(escape))
def _uniq(items): def _uniq(items):
if len(set(items)) == len(items): return list(dict.fromkeys(items))
return items
newitems = []
for item in items:
if item not in newitems:
newitems.append(item)
return newitems
def _parse_sub(source, state, verbose, nested): def _parse_sub(source, state, verbose, nested):
# parse an alternation: a|b|c # parse an alternation: a|b|c
......
...@@ -1708,6 +1708,7 @@ Michael Urman ...@@ -1708,6 +1708,7 @@ Michael Urman
Hector Urtubia Hector Urtubia
Lukas Vacek Lukas Vacek
Ville Vainio Ville Vainio
Yann Vaginay
Andi Vajda Andi Vajda
Case Van Horsen Case Van Horsen
John Mark Vandenberg John Mark Vandenberg
......
Fix performance regression on regular expression parsing with huge
character sets. Patch by Yann Vaginay.
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment