Uh oh!
There was an error while loading. Please reload this page.
gh-80642: timeit - make target time of autorange configurable - #140283
Conversation
- have `timeit` and `repeat` methods (and functions) fall back on `autorange` if the number is set to 0 or None.
…cpython into fix-issue-36461
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
picnixz
commented
Oct 19, 2025
Previously timeit returned a single value. Now it can return a pair if number is 0. This should be better documented because it coule be breaking existing code (I do not know if 0 was a legit value beforehand). I do not think we should expose the handling of number=0 to the timeit method itself. Or if this is the case we should first determine the number by autorange and then pass it to timeit() for the "real" test. I cannot comment on the PR because the mobile app is not working well so I am only commenting here, but please consider this as me requesting changes. |
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
miikka
commented
Oct 22, 2025
When I resurrected this PR, I thought this was a plausibly-useful convenience feature. However, I'm not so sure anymore:
I'm inclined to undo the change. An alternative option would be to provide a new top level convenience method |
miikka
commented
Oct 22, 2025
Looking back at @stevendaprano's original idea, the proposal was that the autorange fallback would be used when |
hugovk
commented
Nov 5, 2025
@picnixz Do you have any preferences here? |
picnixz
commented
Nov 6, 2025
FTR, I've seen your ping Hugo and will reply to this tomorrow or on Saturday (just need some time) |
hugovk
commented
Feb 20, 2026
@picnixz reminder :) |
picnixz
commented
Feb 20, 2026
Sorry Hugo, I saw the ping, then forgot about it. You can usually ping me earlier in general as well :) Now:
So I'm inclined to accept the change for configuring the hardcoded 0.2 (it's not an issue there) but I want another discussion about using |
hugovk
commented
Feb 20, 2026
Yes, sounds reasonable. Once this PR is done, I think we could prompt for further discussion in the issue, and even put @miikka Please can you update this PR? Thanks both! |
miikka
commented
Apr 1, 2026
Hi, sorry for taking a while to get back to this. To recap: the main goal of the PR is make the hardcoded 0.2 seconds configurable in |
picnixz
left a comment
There was a problem hiding this comment.
Thanks. Could you also add a What's New entry for this new feature please?
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Stan Ulbrych <stan@python.org>
miikka
commented
Apr 2, 2026
Added a What's New entry |
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
hugovk
commented
Apr 3, 2026
Thank you! |
…ython#140283) Co-authored-by: Alessandro Cucci <alessandro.cucci@gmail.com> Co-authored-by: blurb-it[bot] <blurb-it[bot]@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Co-authored-by: Stan Ulbrych <stan@python.org> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This is an updated version of PR #12954 with latest main merged in. I also fixed a few issues in the original (it's now consistently called
target_time, there was a float conversion missing, etc.).To quote the original PR:
📚 Documentation preview 📚: https://cpython-previews--140283.org.readthedocs.build/