Skip to content

Commit

Permalink
bpo-43014: Improve performance of tokenize.tokenize by 20-30%
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile committed Jan 24, 2021
1 parent bf9239b commit 15bd9ef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Lib/tokenize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve performance of :mod:`tokenize` by 20-30%. Patch by Anthony Sottile.

0 comments on commit 15bd9ef

Please sign in to comment.