[Python-Dev] time.wallclock()
Kristján Valur Jónsson
kristjan at ccpgames.com
Mon Nov 1 15:00:59 CET 2010
Working on Condition variables and semaphores (see http://bugs.python.org/issue10260) I noticed that time.time() was being used to correctly time blocking system calls. On windows, I would have used time.clock() but reading the documentation made me realize that on Unix that would return CPU seconds which are useless when blocking. However, on Windows, time.clock() has a much higher resolution, apart from being a "wallclock" time, and is thus better suited to timing that time.time(). In addition, time.time() has the potential of giving unexpected results if someone messes with the system clock.
I was wondering if it were helpful to have a function such as time.wallclock() which is specified to give relative wallclock time between invocations or an approximation thereof, to the system's best ability?
We could then choose this to be an alias of time.clock() on windows and time.time() on any other machine, or even have custom implementations on machines that support such a notion.
Kristján
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20101101/2370cb1f/attachment.html>
More information about the Python-Dev
mailing list