diff options
author | Anthony Sottile <asottile@umich.edu> | 2021-05-04 16:53:03 -0700 |
---|---|---|
committer | Anthony Sottile <asottile@umich.edu> | 2021-05-04 16:54:53 -0700 |
commit | 24d348a46a957a52c724f0a56da6ac4b4480f5f5 (patch) | |
tree | 83975dd382b5f7735d624f9433bf8c44690697ab /pycodestyle.py | |
parent | 0f079a061590217515421fc337df8dbf3563fed5 (diff) | |
download | pep8-24d348a46a957a52c724f0a56da6ac4b4480f5f5.tar.gz |
add performance hack to improve tokenize speed
in profiles, this attributed somewhere between 4% and 14% of pycodestyle's execution time
Diffstat (limited to 'pycodestyle.py')
-rwxr-xr-x | pycodestyle.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/pycodestyle.py b/pycodestyle.py index 7f00739..4055716 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -78,6 +78,13 @@ try: 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' |