Skip to content

Conversation

@albertedwardson
Copy link

@albertedwardson albertedwardson changed the title this reduces execution time from ~1500 ns to ~1250 ns this reduces function execution time by ~20% Jul 17, 2025
@albertedwardson albertedwardson changed the title this reduces function execution time by ~20% reduce "module_imports_on_top_of_file" execution time by ~20% Jul 17, 2025
@albertedwardson albertedwardson force-pushed the speedups/module_imports_on_top_of_file branch from 38c0977 to 41e842c Compare July 17, 2025 11:43
@sigmavirus24
Copy link
Member

I wonder if the new profiler in 3.15 would be worth testing here.

I also really wish it were easy to write "benchmark tests" in Python like it is in Go and Rust. I'd love to be continuously verifying nothing regresses on some of these changes and potentially see changes between python versions etc

@albertedwardson
Copy link
Author

New profiler in Python 3.15 does look promising, but I haven't tried it yet.

On the benchmarking side — totally agree. That said, tools like pytest-benchmark and codespeed might help get closer to what you're describing, especially if we ever wanted to track performance across versions or PRs. Could be worth exploring if there’s interest in building out some kind of minimal benchmark harness.

@asottile
Copy link
Member

asottile commented Aug 2, 2025

made some further improvements to get it to about ~50%-60% improvement over baseline

Copy link
Member

@asottile asottile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asottile asottile merged commit db26deb into PyCQA:main Aug 2, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants