Determining actual elapsed (wall-clock) time

Peter Hansen peter at engcorp.com
Sat Jul 2 19:16:08 EDT 2005


Roy Smith wrote:
> Peter Hansen <peter at engcorp.com> wrote:
>>Using time.time() doesn't appear to be suitable, since time might jump 
>>forwards or backwards at the user's whim, if the system clock is reset, 
>>or when a daylight savings time change occurs.
> 
> If you get the UTC time, daylight savings time doesn't enter the equation.  

Hmmm... not only that, but at least under XP the return value of 
time.time() _is_ UTC.  At least, it's entirely unaffected by the 
daylight savings time change, or (apparently) by changes in time zone.

Looks like time.time() might be sufficient.  (That might be what Roy 
intended, but I initially thought he meant time.gmtime(time.time()), 
which could have resulted in a race condition if time.time() jumped 
ahead or back separately from some internal daylight savings time flag, 
and the value was read between the two operations.)

-Peter



More information about the Python-list mailing list