[issue10278] add time.wallclock() method
STINNER Victor
report at bugs.python.org
Fri Sep 2 02:26:00 CEST 2011
STINNER Victor <victor.stinner at haypocalc.com> added the comment:
clock_gettime.patch: add time.clock_gettime() function and time.CLOCK_xxx constants. The patch requires to rerun "autoconf".
For the documentation, I don't know the availability of this function. Is it available on Windows? CLOCK_REALTIME doc contains "Setting this clock requires appropriate privileges": this sentence might be removed if we don't expose clock_settime.
The constants are not defined if the function is not available.
timemodule.c and datetimemodule.c are no more linked to libm. I don't know why libm was used? Copy/paste failure?
On Linux, clock_gettime() requires librt. I chose to check for librt in configure.in. To get this info in setup.py, I close to use the TIMEMODULE_LIBS define (in pyconfig.h). I don't know if there is something simpler.
time.clock_gettime() returns a float. It would be nice to keep nanoseconds as an integer, but I chose a float to mimic other time functions. If we need nanosecond resolution, a new function can be added.
The unit test is very simple, but less than time.clock() test :-)
----------
Added file: http://bugs.python.org/file23083/clock_gettime.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10278>
_______________________________________
More information about the Python-bugs-list
mailing list