[New-bugs-announce] [issue45429] [Windows] time.sleep() should use CREATE_WAITABLE_TIMER_HIGH_RESOLUTION

STINNER Victor report at bugs.python.org
Mon Oct 11 04:28:27 EDT 2021


New submission from STINNER Victor <vstinner at python.org>:

In bpo-21302, the Windows implementation of time.sleep() was modified to use a waitable timer:

New changeset 58f8adfda3c2b42f654a55500e8e3a6433cb95f2 by Victor Stinner in branch 'main':
bpo-21302: time.sleep() uses waitable timer on Windows (GH-28483)
https://github.com/python/cpython/commit/58f8adfda3c2b42f654a55500e8e3a6433cb95f2

It now calls the functions:

* CreateWaitableTimerW()
* SetWaitableTimer()
* WaitForMultipleObjects()

While SetWaitableTimer() has a resolution of 100 ns, the timer has a resolution of 15.6 ms in practice.

We could use the undocumented CREATE_WAITABLE_TIMER_HIGH_RESOLUTION flag with CreateWaitableTimerEx(). See: https://bugs.python.org/issue21302#msg403550

See also:

* https://randomascii.wordpress.com/2013/07/08/windows-timer-resolution-megawatts-wasted/
* https://vstinner.readthedocs.io/windows.html#time

----------
components: Library (Lib)
messages: 403631
nosy: vstinner
priority: normal
severity: normal
status: open
title: [Windows] time.sleep() should use CREATE_WAITABLE_TIMER_HIGH_RESOLUTION
type: enhancement
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45429>
_______________________________________


More information about the New-bugs-announce mailing list