bpo-43014: Improve performance of tokenize.tokenize by 20-30%

This commit is contained in:
Anthony Sottile 2021-01-24 01:23:17 -08:00 committed by GitHub
parent bf9239bb61
commit 15bd9efd01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View file

@ -27,6 +27,7 @@
from builtins import open as _builtin_open
from codecs import lookup, BOM_UTF8
import collections
import functools
from io import TextIOWrapper
import itertools as _itertools
import re
@ -95,6 +96,7 @@ def _all_string_prefixes():
result.add(''.join(u))
return result
@functools.lru_cache
def _compile(expr):
return re.compile(expr, re.UNICODE)

View file

@ -0,0 +1 @@
Improve performance of :mod:`tokenize` by 20-30%. Patch by Anthony Sottile.