diff --git a/pep-0418.txt b/pep-0418.txt index 79ad7271e..e26ff3259 100644 --- a/pep-0418.txt +++ b/pep-0418.txt @@ -137,7 +137,7 @@ system time. It is available on all platforms and cannot fail. -Pseudo-code [#pseudo]_: :: +Pseudo-code:: def hires(): if hires.use_monotonic: @@ -158,11 +158,15 @@ Monotonic mach_absolute_time ^^^^^^^^^^^^^^^^^^ -Mac OS X provides a monotonic clock: mach_absolute_time(). mach_timebase_info() -provides a fraction to convert the clock value to a number of nanoseconds. +Mac OS X provides a monotonic clock: mach_absolute_time(). It is based on +absolute elapsed time delta since system boot. It is not adjusted and cannot be +set. -According to the documentation, mach_timebase_info() is always equals to one -and does never fail, even if the function may fail according to its prototype. +mach_timebase_info() gives a fraction to convert the clock value to a number of +nanoseconds. According to the documentation (`Technical Q&A QA1398 +`_), mach_timebase_info() +is always equals to one and does never fail, even if the function may fail +according to its prototype. mach_absolute_time() has a resolution of 1 nanosecond. @@ -189,7 +193,7 @@ requires a kernel version 2.6.28 or later. clock_getres() gives the clock resolution. It is 1 nanosecond on Linux. .. note:: - clock_gettime() requires to link the program with the realtime ("rt") library. + clock_gettime() requires to link the program to the rt (real-time) library. QueryPerformanceCounter ^^^^^^^^^^^^^^^^^^^^^^^ @@ -197,7 +201,6 @@ QueryPerformanceCounter High-resolution performance counter. It is monotonic. QueryPerformanceFrequency() gives its frequency. - On Windows XP, QueryPerformanceFrequency() is the processor frequency and QueryPerformanceCounter() is the TSC of the current processor. Windows XP had a bug (see `KB896256 `_): on a @@ -315,9 +318,9 @@ Alternatives: API design One function with a flag: time.monotonic(strict=False) ---------------------------------------------------------- - * time.monotonic(strict=False) falls back to another clock if no monotonic clock - is not available or does not work, but it does never fail. - * time.monotonic(strict=True) raises OSError if monotonic clock fails or + * time.monotonic(strict=False) falls back to the system clock if no monotonic + clock is available or if the monotonic clock failed. + * time.monotonic(strict=True) raises OSError if monotonic clock fails and NotImplementedError if the system does not provide a monotonic clock "A keyword argument that gets passed as a constant in the caller is usually