time module precision

Jane Austine janeaustine50 at hotmail.com
Sat Jan 8 23:13:49 EST 2005


What is the precision (and accuracy) of time module on a Windows XP
machine?

threading module depends on time module so it's precision(and
accuracy) is up to time module's.

| for i in xrange(1000):
|    time.sleep(0.001)

This sleeps for awhile, which means 0.001 sec is not ignored. On the
other hand,

| for i in xrange(10000):
|    time.sleep(0.0001)

This returns right away. 0.0001 sec is ignored and lost in the air.

So can I tell the time.sleep's precision is 1ms? Any other way to
increase the precision? (Using busy waiting -- spinning loop -- is not
a good option, it makes over 90% cpu usage)

Jane



More information about the Python-list mailing list