logging module -- better timestamp accuracy on Windows

Vinay Sajip vinay_sajip at yahoo.co.uk
Wed Feb 16 16:32:39 CET 2011


On Feb 16, 2:30 pm, benhoyt <benh... at gmail.com> wrote:

> It seems to me that the logging module should use a millisecond-accurate timestamp (time.clock) on Windows,
> just like the "timeit" module does.

It's not an unreasonable request, though I don't think logging should
be used to time things accurately. I'm also not sure about the exact
form the solution might take. For example, are you assuming that your
clock() call in logging is the very first call made? If it's not, then
wouldn't this throw your calculations off? Or have I misunderstood how
clock() works? Also, IIUC the resolution of clock() is < 1 usec, but
as logging only prints to the nearest msec, won't you lose much of the
benefit of the increased resolution? In your above example your
request processing took 0.56 msec, so at best you would see a 1 msec
difference between start and finish times in the log - that doesn't
seem like it would be good enough; plus, if the process took less than
0.5 msec, then you might see identical start and finish times in the
log. Or are you saying that the times should be formatted/printed to
microsecond accuracy?

Of course 3.2 is at rc3, and branches for 2.x are closed except for
security fixes, so I'm not sure when this could go in to an official
release ...

Thanks & regards,

Vinay Sajip




More information about the Python-list mailing list