mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-37723: Fix performance regression on regular expression parsing. (GH-15030)
Improve performance of sre_parse._uniq function.
This commit is contained in:
parent
1b29af83bc
commit
9f55551f3d
3 changed files with 4 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue