summaryrefslogtreecommitdiff
path: root/src/flake8
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2018-10-14 21:45:58 -0700
committerAnthony Sottile <asottile@umich.edu>2018-10-14 21:50:24 -0700
commit6a610cb5d6e108dfa9c72809da04256d9b7236c9 (patch)
treeafc9b253a1849bba2228dd0cc90d3ca72ddf1c40 /src/flake8
parent9631dac52aa6ed8a3de9d0983c3c7b0267ae7d6d (diff)
downloadflake8-6a610cb5d6e108dfa9c72809da04256d9b7236c9.tar.gz
Defer setuptools import to save ~60ms on startup
(I ran this 5 times and picked a median result) ### before ```console $ time flake8 --help > /dev/null real 0m0.221s user 0m0.199s sys 0m0.020s ``` ### after ```console $ time flake8 --help > /dev/null real 0m0.169s user 0m0.144s sys 0m0.020s ```
Diffstat (limited to 'src/flake8')
-rw-r--r--src/flake8/main/debug.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/flake8/main/debug.py b/src/flake8/main/debug.py
index ca3827e..ac52494 100644
--- a/src/flake8/main/debug.py
+++ b/src/flake8/main/debug.py
@@ -4,8 +4,6 @@ from __future__ import print_function
import json
import platform
-import setuptools
-
def print_information(option, option_string, value, parser,
option_manager=None):
@@ -65,4 +63,7 @@ def plugins_from(option_manager):
def dependencies():
"""Generate the list of dependencies we care about."""
+ # defer this expensive import, not used outside --bug-report
+ import setuptools
+
return [{'dependency': 'setuptools', 'version': setuptools.__version__}]