Skip to content

Commit

Permalink
Merge pull request PyCQA#993 from asottile/perf_hack
Browse files Browse the repository at this point in the history
add performance hack to improve tokenize speed
  • Loading branch information
asottile authored May 6, 2021
2 parents 8ba139d + 24d348a commit aa3417b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pycodestyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ def lru_cache(maxsize=128): # noqa as it's a fake implementation.
except ImportError:
from ConfigParser import RawConfigParser

# this is a performance hack. see https://bugs.python.org/issue43014
if (
sys.version_info < (3, 10) and
callable(getattr(tokenize, '_compile', None))
): # pragma: no cover (<py310)
tokenize._compile = lru_cache()(tokenize._compile) # type: ignore

__version__ = '2.7.0'

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

0 comments on commit aa3417b

Please sign in to comment.