Python's Import Tax Measured Across 63,431 Runs: p99 Is 354 ms and Lazy Mode Breaks 8 of 414 Top Packages
The first systematic measurement of PyPI import cost covers the 500 most-downloaded packages sampled quarterly over five years of releases, under CPython 3.9 through 3.14, on Apple M5/macOS and Intel Xeon/Linux, for 63,431 measurements. The distribution is heavily skewed: half of packages import in under 6 ms but the 99th percentile is 354 ms, the first import after installation costs 3-22x more because of bytecode compilation, and importing a package's submodules can cost up to 294x the top-level import that benchmarks actually report. Median cost grows only 1.6-2.4%/year while the mean grows 11-13%/year, newer interpreters import the same code 1.16x slower on macOS but not Linux, a single point release (3.11.5 vs 3.11.16) swings cost by 1.34x, and Python 3.15's PEP 810 global lazy mode makes imports essentially free but breaks 8 of 414 top packages.
↳ Follow the thread