This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: time.monotonic docstring does not mention the time unit returned
Type: Stage:
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: nicholas.riley, vstinner
Priority: normal Keywords: patch

Created on 2012-03-12 23:24 by nicholas.riley, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
monotonic-doc.patch nicholas.riley, 2012-03-13 00:38 review
Messages (5)
msg155518 - (view) Author: Nicholas Riley (nicholas.riley) * Date: 2012-03-12 23:24
Currently:


>>> help(time.monotonic)
Help on built-in function monotonic in module time:

monotonic(...)
    monotonic() -> float
    
    Monotonic clock. The reference point of the returned value is undefined so
    only the difference of consecutive calls is valid.
msg155525 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2012-03-12 23:36
time.monotonic() has 3 implementations:

* Windows: QueryPerformanceCounter() with QueryPerformanceFrequency()
* Mac OS X: mach_absolute_time() with mach_timebase_info()
* UNIX: clock_gettime(CLOCK_MONOTONIC_RAW) or clock_gettime(CLOCK_MONOTONIC)

QueryPerformanceFrequency() returns the frequency "in counts per second" according to the doc.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms644905(v=vs.85).aspx

mach_absolute_time() with mach_timebase_info() returns a number of seconds, but Python uses *1e-9.

clock_gettime() uses a timespec structure and Python uses *1e-9.

It looks like to mention that time.monotonic() unit is seconds.
msg155541 - (view) Author: Nicholas Riley (nicholas.riley) * Date: 2012-03-13 00:38
According to http://juliusdavies.ca/posix_clocks/clock_realtime_linux_faq.html, CLOCK_REALTIME can go backwards. CLOCK_MONOTONIC_RAW is best where available (like QueryPerformanceFrequency / mach_absolute_time) and CLOCK_MONOTONIC is pretty good.

So I have updated both the docs for time.monotonic and time.wallclock to hopefully better explain things... may need to be another issue here too.
msg156331 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2012-03-19 12:15
The unit (seconds) is not mentioned in the doc. Related changesets: 27441e0d6a75 and c11946846474.
msg156332 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2012-03-19 12:15
> The unit (seconds) is not mentioned in the doc

The unit (seconds) is *now* mentioned in the doc
History
Date User Action Args
2022-04-11 14:57:27adminsetgithub: 58485
2012-03-19 12:15:37vstinnersetmessages: + msg156332
2012-03-19 12:15:11vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg156331
2012-03-13 00:38:47nicholas.rileysetfiles: + monotonic-doc.patch
keywords: + patch
messages: + msg155541
2012-03-12 23:36:20vstinnersetnosy: + vstinner
messages: + msg155525
2012-03-12 23:24:43nicholas.rileycreate