Tue Nov 11 18:19:29 EST 2008

Python Time

Here are some interesting things I've learned about handling time in python (for windows)

1) time.time() has millisecond precision on a Windows machine, and microsecond precision on a Mac or Linux machine. 2) datetime.dateime is the same 3) time.clock() gives seconds since the process was started at much greater precision, but it is not portable (windows only). Also it is not clear how quickly time.clock() updates, nor how one would correlate it’s output with system time since it is a relative measure.

By comparison, MATLAB on windows reports time in about 2e-7 second steps. (I determined this with

t = zeros(1,10000)
for x = 1:length(t)
    t(x) = now

plot( t - t(1), '.')

We have successfully using MATLAB’s now function to time the arrival of serial strings that contain GPS time stamps and then used these as a lookup table to determine the UTC time of other events that have also been time-stamped with the now function. However the coarseness of python’s abilities to time stamp things in windows is going to make this hard. Hmm.


Posted by vschmidt | Permanent link | File under: python