win-precise-time
raw JSON → 1.4.2 verified Mon Apr 27 auth: no python
Windows-only library providing precise time measurement and sleep functions using high-resolution performance counters and multimedia timers. At version 1.4.2, it supports Python >=3.7 and is actively maintained.
pip install win-precise-time Common errors
error ImportError: No module named 'win_precise_time' ↓
cause Attempting to import on non-Windows OS.
fix
Wrap import: if os.name == 'nt': from win_precise_time import ...
error AttributeError: module 'win_precise_time' has no attribute 'precise_sleep' ↓
cause Typo in function name (case-sensitive).
fix
Use correct function name: precise_sleep (all lowercase).
Warnings
breaking Only works on Windows; raises ImportError on other platforms. ↓
fix Guard imports with platform checks.
gotcha precise_sleep() blocks the calling thread; cannot be interrupted by signals. ↓
fix Use threading or subprocess if interruptibility required.
Imports
- precise_sleep
from win_precise_time import precise_sleep
Quickstart
from win_precise_time import precise_sleep, precise_time
import os
if os.name != 'nt':
print('This library is Windows-only.')
exit()
t = precise_time()
print(f'Start time: {t}')
precise_sleep(0.001)
print(f'Elapsed: {precise_time() - t}')