Message 403550 - Python tracker

Message403550

Author eryksun
Recipients Livius, akira, eryksun, python-dev, shankarunni, vstinner, yselivanov
Date 2021-10-09.19:47:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1633808879.94.0.527881496304.issue21302@roundup.psfhosted.org>
In-reply-to
Content
> 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).
History
Date User Action Args
2021-10-09 19:47:59eryksunsetrecipients: + eryksun, vstinner, akira, python-dev, yselivanov, shankarunni, Livius
2021-10-09 19:47:59eryksunsetmessageid: <1633808879.94.0.527881496304.issue21302@roundup.psfhosted.org>
2021-10-09 19:47:59eryksunlinkissue21302 messages
2021-10-09 19:47:59eryksuncreate