| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
By the way, what's the reason for importing with underscores? import collections as _collections
import sys as _sys
import types as _types
from io import StringIO as _StringIO |
Sorry, something went wrong.
There was a problem hiding this comment.
Looks fine -- I wouldn't change the whitespace personally but up to you.
collections you could do by hardcoding the repr and adding a test that they're the same? I agree probably not worth it, though.
A
Sorry, something went wrong.
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
Improves import time by up to seven times. Measured with a PGO and LTO non-debug build on macOS.
The slowest import in pprint is dataclasses (taking 0.0012s / 55.2% of import time), and used in only two functions.
After deferring dataclasses, the next is re (0.005s / 30.1% of the new import time), only used in one function.
After deferring re, the next are collections (0.002s / 14.8%) and types (0.000s / 2.4%). I left these, as their times are low and they're less straightforward to defer.
-X importtime
Running: pip install tuna && ./python.exe -X importtime -c 'import pprint' 2> import.log && tuna import.log
total import time: 0.022s -> 0.011s = x2 as fast
pprint import time: 0.014s -> 0.002s = x7 as fast
hyperfine: 19.2 ms -> 10.4 ms = x1.8 as fast
main
PR
Also add some PEP 8 whitespace to remove some distracting IDE warnings.