ANN: a new utility for Python developers

Erno Kuusela erno at iki.fi
Tue Aug 21 22:50:02 CEST 2001


On Tue, 21 Aug 2001, Skip Montanaro wrote:

| The time module is supposed to be a very
| thin wrapper around various time-related C library functions.
[snip explanation what time.time()/time.clock() do on various platforms]

yeah, really thin wrapper... actually perhaps it would be better
if time.time() called the c time() function and time.clock() called
the c clock() function. then, new functions could be introduced for
measuring time accurately and for measuring only cpu time.
the former could call gettimeofday on unix and read the time stamp
counter on windows, and the latter could use clock or times and fail,
be absent or fall back to the performance counter on windows.

| I think if there was a better solution, Guido and friends would have
| found it by now.

yes, but as i understand the way it works is he picks up brilliant
ideas from frothing rants on the newsgroup and then gets in the time
machine... and then he will have found it by now.

that's why there are only pointless threads left on the newsgroup. all
the sensible threads have been erased from history because whatever
they were complaining about no longer exists :)

|     Erno> 1) it is usually better to use gettimeofday(2) than times(2) on
|     Erno>    unix for timing code because times(2) has poor resolution and
|     Erno>    the user/system time numbers are frequently gibberish.
| 
|     Erno> 2) the python time.clock() should return information based on
|     Erno>    gettimeofday(2) and not times(2) on unix.
| 
| times() is not used anywhere in timemodule.c.

oops, forgot to mention that clock(3) uses times(2) on unix.

   -- erno




More information about the Python-list mailing list