Skip to content

Commit aa3417b

Browse files
authored
Merge pull request #993 from asottile/perf_hack
add performance hack to improve tokenize speed
2 parents 8ba139d + 24d348a commit aa3417b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pycodestyle.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ def lru_cache(maxsize=128): # noqa as it's a fake implementation.
7878
except ImportError:
7979
from ConfigParser import RawConfigParser
8080

81+
# this is a performance hack. see https://bugs.python.org/issue43014
82+
if (
83+
sys.version_info < (3, 10) and
84+
callable(getattr(tokenize, '_compile', None))
85+
): # pragma: no cover (<py310)
86+
tokenize._compile = lru_cache()(tokenize._compile) # type: ignore
87+
8188
__version__ = '2.7.0'
8289

8390
DEFAULT_EXCLUDE = '.svn,CVS,.bzr,.hg,.git,__pycache__,.tox'

0 commit comments

Comments
 (0)