Eryk Sun <eryk...@gmail.com> added the comment:

> In Python 3.11, time.sleep() is now always implemented with a 
> waitable timer. 

A regular waitable timer in Windows becomes signaled with the same resolution 
as Sleep(). It's based on the current interrupt timer period, which can be 
lowered to 1 ms via timeBeginPeriod(). Compared to Sleep() it's more flexible 
in terms of periodic waits, WaitForMultipleObjects(), or 
MsgWaitForMultipleObjects() -- not that time.sleep() needs this flexibility.

That said, using a waitable timer leaves the door open for improvement in 
future versions of Python. In particular, it's possible to get higher 
resolution in newer versions of Windows 10 and Windows 11 with 
CreateWaitableTimerExW() and the undocumented flag 
CREATE_WAITABLE_TIMER_HIGH_RESOLUTION (2).

----------
nosy: +eryksun

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue21302>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to