[issue21302] time.sleep (floatsleep()) should use clock_nanosleep() on Linux

Benjamin Szőke report at bugs.python.org
Sun Oct 10 06:37:16 EDT 2021


Benjamin Szőke <egyszeregy at freemail.hu> added the comment:

It is not true that there are no benefits. Absolute timeout using can reduce the overhead time of any variable and object intialization cost before the WaitForMultipleObjects() which will perform the real sleeping via blocking wait in pysleep(). GetSystemTimePreciseAsFileTime() must be call at the first line as much as it can in pysleep(). This is the same implementation in Linux via clock_nanosleep().

So, to using absolute timeout and GetSystemTimePreciseAsFileTime() can improves the accuracy of the desired sleep time. For example if sleep = 2.0 sec then real relative sleep time = 2.001234 sec, but absolute sleep time = 2.000012 sec.

Benefits are in not the technicaly backgorund, rather it is in the usecase.

----------

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


More information about the Python-bugs-list mailing list