win-precise-time#
Description#
This Windows-only library provides a few improvements over the builtin time
functions.
The Timestamp Functions of win-precise-time
achieve a much better resolution than the builtin function
by using GetSystemTimePreciseAsFileTime. On Windows the builtin time.time()
function has a resolution of 15ms
while win_precise_time.time()
has nanosecond resolution as seen in the Timestamp Resolution Example.
The Sleep Functions use high resolution timers to enable sleep with sub-milliseconds precision. This change was also implemented in CPython 3.11. High resolution timers are supported in Windows 10 version 1803 and later. Older Windows versions will not see any sleep precision improvement with this library.
All functions of this library are implemented in C.
Installation#
You can install win-precise-time
from PyPI:
python -m pip install win-precise-time
Usage#
>>> import win_precise_time as wpt
>>> wpt.time() # retrieve current time
1654539449.4548845
>>> wpt.sleep(0.001) # sleep for 1ms
Test#
Run the tests with:
python -m pip install tox
tox
Build#
Build win-precise-time
with:
python -m pip install build
python -m build .
License#
win-precise-time
is distributed under the terms of the MIT license.