You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
Activity
vstinner commentedon Jan 24, 2012
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.
terryjreedy commentedon Jan 27, 2012
Do we actually yet another function, or could this be covered by adding a parameter such as monotonic=False, perhaps to wallclock().
vstinner commentedon Jan 29, 2012
A monotonic is a different clock, it would be surprising that an
argument uses another clock.
merwok commentedon Feb 3, 2012
I don’t understand why this new function would be useful. Time-related modules in Python are already complicated.
bitdancer commentedon Feb 3, 2012
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.
merwok commentedon Feb 3, 2012
Thanks, now I see the usefulness.
python-dev commentedon Feb 7, 2012
New changeset 376ce937823c by Victor Stinner in branch 'default':
Issue bpo-13846: Add time.monotonic(), monotonic clock.
http://hg.python.org/cpython/rev/376ce937823c
merwok commentedon Feb 8, 2012
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.
pitrou commentedon Feb 20, 2012
Boost has a monotonic time implementation (steady_clock) for OS X:
http://svn.boost.org/svn/boost/trunk/boost/chrono/detail/inlined/mac/chrono.hpp
python-dev commentedon Feb 23, 2012
New changeset 50b1f2d07011 by Victor Stinner in branch 'default':
Issue bpo-13846: Enhance time.monotonic() documentation
http://hg.python.org/cpython/rev/50b1f2d07011
vstinner commentedon Feb 23, 2012
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.