New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add time.monotonic() function #58054
Comments
After time.wallclock() (issue bpo-10278), let add a time.monotomic() function. It is similar to time.wallclock() (try to get the most accurate clock) but is not available if the system doesn't provide a monotonic clock. It may also fail at runtime if Python cannot find a monotonic clock, whereas time.clock() and time.wallclock() fallback on a wallclock which may go backward on NTP adjust. The documentation of the patch should be improved :-) wallclock() tests may be simplified or dropped because they may fail on NTP adjust. |
Do we actually yet another function, or could this be covered by adding a parameter such as monotonic=False, perhaps to wallclock(). |
A monotonic is a different clock, it would be surprising that an |
I don’t understand why this new function would be useful. Time-related modules in Python are already complicated. |
If you are trying to time something (an interval), having the time go backward can really screw up your data. And that *will* happen on a system that is running NTP (or even just resets its time). monotonic clocks were introduced at the OS level for a reason, and it seems reasonable for Python to expose them (when the are available) like it does other system resources. |
Thanks, now I see the usefulness. |
New changeset 376ce937823c by Victor Stinner in branch 'default': |
Victor, I think the doc doesn’t say why the function is useful for people like me who don’t already know it. David’s explanation could be reused. |
Boost has a monotonic time implementation (steady_clock) for OS X: |
New changeset 50b1f2d07011 by Victor Stinner in branch 'default': |
I opened a new issue for Mac OS X: bpo-14104. -- @Éric: I enhanced the doc. Feel free to complete or rewrite it if you have better information about such clocks. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: