Closed danielhollas closed 2 months ago
Attempting to disentangle the performance impacts of json
and platform
:
importlib_metadata main 🐚 .tox/py/bin/python -Ximporttime -c "import importlib_metadata" 2>1 | grep -E r'platform|\sjson$|importlib_metadata$'
import time: 89 | 800 | json
import time: 221 | 251 | platform
import time: 636 | 13692 | importlib_metadata
importlib_metadata main 🐚 800/13692
0.05842827928717499
importlib_metadata main 🐚 251/13692
0.018331872626351154
I see json
accounts for ~6% of the startup and platform
under 2% (on my machine under Python 3.12).
Staged on top of #502
platform
andjson
modules take together around 1.5ms to import, around 10% of total import time. Since they are both used in a single place it probably makes sense to inline their import.After this PR, this is an output of
python -Ximporttime -c "import importlib_metadata"
visualized with tuna using cpython main branch.