I ran a full suite of pyperformance
benchmarks to see how badly Lazy Imports affects CPython performance.
In the experiments I ran, I contemplated three scenarios (all on top of CPython 3.12, Main branch):
- Vanilla vs. Lazy Imports Implementation Disabled - To see if Lazy Imports (if it is disabled and not used) brings any penalties to CPython performance.
- Vanilla vs. Lazy Imports Implementation Enabled - To see if it brings penalties to those wanting to use Lazy Imports but are concerned about giving up on any Vanilla CPython performance.
- Lazy Imports Implementation Disabled vs Imports Implementation Enabled - To see what would later be the penalty to someone not yet using Lazy Imports who wants to start using it.
I used a dedicated Amazon EC2 Bare Metal machine with 72 logical cores. The results are in the following link in my CPython fork. For those interested, you can also find the .json
files produced by pyperformance
in the /lazy_imports-pyperformance
directory in the lazy_imports-pyperformance branch.
Please, share any feedback, comments or concerns. Thank you!
Edit: I re-run the experiments and updated in the link. I’m terribly sorry I did mess up the previous run. Thank you for spotting the possibility @markshannon!