diff options
author | Anthony Sottile <asottile@umich.edu> | 2021-01-24 09:23:17 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-24 09:23:17 (GMT) |
commit | 15bd9efd01e44087664e78bf766865a6d2e06626 (patch) | |
tree | fb8e08f13fa8352c0187f235232c3ed03aae9edb /Lib | |
parent | bf9239bb61fda25efe89d53a60675528b2f3ce6f (diff) | |
download | cpython-15bd9efd01e44087664e78bf766865a6d2e06626.zip cpython-15bd9efd01e44087664e78bf766865a6d2e06626.tar.gz cpython-15bd9efd01e44087664e78bf766865a6d2e06626.tar.bz2 |
bpo-43014: Improve performance of tokenize.tokenize by 20-30%
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/tokenize.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/tokenize.py b/Lib/tokenize.py index 1aee21b..42c1f10 100644 --- a/Lib/tokenize.py +++ b/Lib/tokenize.py @@ -27,6 +27,7 @@ __credits__ = ('GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, ' 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) |