[Python-Dev] this is why we shouldn't call it a "monotonic clock" (was: PEP 418 is too divisive and confusing and should be postponed)

Victor Stinner victor.stinner at gmail.com
Mon Apr 9 02:00:32 CEST 2012

> IOW "What's good enough for sleep() is good enough for
> user-implemented timeouts and scheduling." as a way to reach at least
> one decision for a platform with agreed-upon cross-platform
> characteristics that are useful.

sleep() is implemented in the kernel. The kernel is notified when a
clock is set, and so can choose how to handle time adjustement. Most
"sleeping" functions use the system clock but don't care of clock

> I personally have a need for one potentially different clock -- to
> measure short intervals for benchmarks and profiling. This might be
> called time.performancetimer()?

I deferred this topic because it is unclear to me if such timer has to
count elapsed time during a sleep or not. For example, time.clock()
does on UNIX, whereas it doesn't on Windows. You may need two clocks
for this:
 * time.perf_counter(): high-resolution timer for benchmarking, count
time elasped during a sleep
 * time.process_time(): High-resolution (?) per-process timer from the
CPU. (other possible names: time.process_cpu_time() or

On Windows, GetProcessTimes() has not a "high-resolution": it has a
accuracy of 1 ms in the best case. QueryPerformanceCounter() counts
time elapsed during a sleep, I don't know for GetProcessTimes.


More information about the Python-Dev mailing list