Datetime with float seconds
gagsl-py2 at yahoo.com.ar
Thu Aug 6 02:54:07 CEST 2009
En Wed, 05 Aug 2009 09:50:04 -0300, kpal <kpalamartchouk at gmail.com>
> The standard datetime has 1 microsecond granularity.
Note that this is the finest granularity a datetime object can store, NOT
the precision of datetime.now() by example.
> My application
> needs finer time resolution, preferably float seconds.
"float seconds" doesn't mean much. time.time returns float seconds, but
its precision is around 15ms on Windows.
> Is there an
> alternative to the out-of-the-box datetime? Timezone support is not
On Windows, use time.clock(), which internally uses
QueryPerformanceCounter. The resolution depends on your hardware, but it's
typically better than 1 microsecond. If you want to know the actual value:
py> from ctypes import *
py> plonglong = POINTER(c_longlong)
py> QueryPerformanceFrequency.argtypes = [plonglong]
py> freq = c_longlong()
That is, on my system the resolution is 1/3579545s, or better than 300ns
More information about the Python-list