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

2021-10-11 Thread STINNER Victor
STINNER Victor added the comment: This issue is closed. If you consider that time.sleep() has a bug or could be enhanced, please open a new issue. -- ___ Python tracker ___

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

2021-10-11 Thread STINNER Victor
STINNER Victor added the comment: > 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

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

2021-10-10 Thread Eryk Sun
Eryk Sun added the comment: > Absolute timeout using can reduce the overhead time of any variable > and object intialization cost before the WaitForMultipleObjects() Again, timer objects store the due time in interrupt time, not system time (i.e. InterruptTime vs SystemTime in the

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

2021-10-10 Thread Benjamin Szőke
Benjamin Szőke added the comment: In other words, using absolute timeout can eliminate the systematic error of desired sleep time. -- ___ Python tracker ___

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

2021-10-10 Thread Benjamin Szőke
Benjamin Szőke 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().

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

2021-10-09 Thread Eryk Sun
Eryk Sun added the comment: > Is there any benefit of calling SetWaitableTimer() with an > absolute timeout No, the due time of a timer object is stored in absolute interrupt time, not absolute system time. This has to be calculated either way, and it's actually more work for the kernel if

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

2021-10-09 Thread Benjamin Szőke
Benjamin Szőke added the comment: Absolute timeout implementation via SetWaitableTimer() and GetSystemTimePreciseAsFileTime() is always better because it can reduce the "waste time" or "overhead time" what is always exist in any simple interval sleep implementation. Moreover, it is the only

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

2021-10-09 Thread Eryk Sun
Eryk Sun 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

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

2021-10-09 Thread STINNER Victor
STINNER Victor added the comment: > it is time to use nicely GetSystemTimePreciseAsFileTime() in time.time() See bpo-19007 for that. > it is time to (...) time.sleep() as absolute sleeping because it is available > since Windows 8. In Python 3.11, time.sleep() is now always implemented

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

2021-10-09 Thread Benjamin Szőke
Benjamin Szőke added the comment: https://www.python.org/downloads/windows/ "Note that Python 3.10.0 cannot be used on Windows 7 or earlier." vstinner: Is it true that Windows 7 is not supported OS anymore? In this case we do not need to care about Windows 7 and earlier Windows OS

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

2021-09-25 Thread STINNER Victor
STINNER Victor added the comment: > Do you have any information about when will be it released in 3.11? Here is a schedule of Python 3.11 releases: https://www.python.org/dev/peps/pep-0664/ In the meanwhile, you can develop a C extension to get the feature. --

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

2021-09-25 Thread Benjamin Szőke
Benjamin Szőke added the comment: Do you have any information about when will be it released in 3.11? -- ___ Python tracker ___ ___

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

2021-09-25 Thread STINNER Victor
STINNER Victor added the comment: Thanks Livius for all these nice enhancements! -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker

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

2021-09-25 Thread STINNER Victor
STINNER Victor added the comment: New changeset 7834ff26cbcd4d8394d64d80d9f51a364d38b1c6 by Victor Stinner in branch 'main': bpo-21302: Add nanosleep() implementation for time.sleep() in Unix (GH-28545) https://github.com/python/cpython/commit/7834ff26cbcd4d8394d64d80d9f51a364d38b1c6

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

2021-09-24 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +26929 pull_request: https://github.com/python/cpython/pull/28545 ___ Python tracker ___

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

2021-09-22 Thread Benjamin Szőke
Change by Benjamin Szőke : -- pull_requests: +26917 pull_request: https://github.com/python/cpython/pull/28526 ___ Python tracker ___

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

2021-09-22 Thread STINNER Victor
STINNER Victor added the comment: See also bpo-19007: "precise time.time() under Windows 8: use GetSystemTimePreciseAsFileTime". -- ___ Python tracker ___

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

2021-09-22 Thread STINNER Victor
STINNER Victor added the comment: Livius: do you care about using nanosleep(), or can I close the issue? -- ___ Python tracker ___

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

2021-09-22 Thread STINNER Victor
STINNER Victor added the comment: > On Windows with a Python 3.11 debug build, I get: > Mean +- std dev: 21.9 ms +- 7.8 ms (228 values) I wrote an optimization to cache the Windows timer handle between time.sleep() calls (don't close it). I don't think that it's needed because they shortest

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

2021-09-22 Thread STINNER Victor
STINNER Victor added the comment: bench.py: measure the shortest possible sleep. Use time.sleep(1e-10): 0.1 nanosecond. It should be rounded to the resolution of the used sleep function, like 1 ns on Linux. On Linux with Fedora 34 Python 3.10 executable, I get: Mean +- std dev: 60.5 us

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

2021-09-22 Thread STINNER Victor
STINNER Victor added the comment: Livius: your first PR modified Sleep() in Modules/_tkinter.c to use nanosleep(). I don't see the point since this function has a solution of 1 ms (10^-3). Using select() on Unix is enough: resolution of 1 us (10^-6). --

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

2021-09-22 Thread STINNER Victor
STINNER Victor added the comment: 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 --

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

2021-09-20 Thread STINNER Victor
STINNER Victor added the comment: wait.py: script to test the time.sleep() function. Press CTRL+C multiple times during the sleep to check that even if the sleep is interrupted, time.sleep() sleeps the expected duration. -- Added file: https://bugs.python.org/file50289/wait.py

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

2021-09-20 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +26882 pull_request: https://github.com/python/cpython/pull/28483 ___ Python tracker ___

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

2021-09-15 Thread STINNER Victor
STINNER Victor added the comment: New changeset b49263b698993cad2b8aaddc55cdeaa678412b30 by Victor Stinner in branch 'main': bpo-21302: Add _PyTime_AsNanoseconds() (GH-28350) https://github.com/python/cpython/commit/b49263b698993cad2b8aaddc55cdeaa678412b30 --

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

2021-09-15 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +26764 pull_request: https://github.com/python/cpython/pull/28350 ___ Python tracker ___

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

2021-09-14 Thread Benjamin Szőke
Change by Benjamin Szőke : -- pull_requests: +26754 pull_request: https://github.com/python/cpython/pull/28341 ___ Python tracker ___

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

2021-09-13 Thread STINNER Victor
STINNER Victor added the comment: New changeset 85dc53a463967659075744ad911d08a32aa70dd5 by Victor Stinner in branch 'main': bpo-21302: Update time.sleep() doc for clock_nanosleep() (GH-28311) https://github.com/python/cpython/commit/85dc53a463967659075744ad911d08a32aa70dd5 --

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

2021-09-13 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +26724 pull_request: https://github.com/python/cpython/pull/28311 ___ Python tracker ___

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

2021-09-13 Thread STINNER Victor
STINNER Victor added the comment: New changeset 85a4748118c3793be7047ecbcbfc79dd07cb2a75 by Livius in branch 'main': bpo-21302: Add clock_nanosleep() implementation for time.sleep() (GH-28111) https://github.com/python/cpython/commit/85a4748118c3793be7047ecbcbfc79dd07cb2a75 --

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

2021-09-05 Thread Benjamin Szőke
Benjamin Szőke added the comment: Can you review my final implementation? https://github.com/python/cpython/pull/28111 -- versions: +Python 3.11 ___ Python tracker ___

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

2021-09-01 Thread Benjamin Szőke
Change by Benjamin Szőke : -- nosy: +Livius nosy_count: 5.0 -> 6.0 pull_requests: +26552 pull_request: https://github.com/python/cpython/pull/28111 ___ Python tracker ___

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

2021-08-30 Thread Roundup Robot
Change by Roundup Robot : -- keywords: +patch nosy: +python-dev nosy_count: 4.0 -> 5.0 pull_requests: +26521 stage: -> patch review pull_request: https://github.com/python/cpython/pull/28077 ___ Python tracker

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

2014-04-26 Thread STINNER Victor
STINNER Victor added the comment: I know that an earlier request to use nanosleep() has been rejected as wontfix It was the issue #13981. I created this issue while I worked on the PEP 410 (nanosecond timestamp). I closed the issue myself, it doesn't mean that Python must not use the

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

2014-04-26 Thread STINNER Victor
STINNER Victor added the comment: I'm working on a patch, but I noticed a similar issue in Condition.wait(), which also keeps re-evaluating the remaining sleep time based on the current kernel clock, with similar effects. I see that Lock.acquire(timeout) uses the C function gettimeofday() to

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

2014-04-26 Thread STINNER Victor
STINNER Victor added the comment: If you want to modify time.sleep(), you must be careful of the portability: Windows, Linux, but also Mac OS X, FreeBSD, Solaris, etc. Try to describe the behaviour of each underlying C function on each platform to be able to describe the portable behaviour on

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

2014-04-26 Thread Shankar Unni
Shankar Unni added the comment: If you want to modify time.sleep(), you must be careful of the portability: Windows, Linux, but also Mac OS X, FreeBSD, Solaris, etc. Oh, I totally agree. What I'm trying to do is to define another autoconf flag (HAVE_CLOCK_NANOSLEEP), that does a feature

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

2014-04-26 Thread STINNER Victor
STINNER Victor added the comment: 2014-04-27 2:26 GMT+02:00 Shankar Unni rep...@bugs.python.org: If you want to modify time.sleep(), you must be careful of the portability: Windows, Linux, but also Mac OS X, FreeBSD, Solaris, etc. Oh, I totally agree. What I'm trying to do is to define

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

2014-04-19 Thread akira
Changes by akira 4kir4...@gmail.com: -- nosy: +akira ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21302 ___ ___ Python-bugs-list mailing list

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

2014-04-18 Thread Shankar Unni
New submission from Shankar Unni: I know that an earlier request to use nanosleep() has been rejected as wontfix, but I'm filing this one for a different reason. Today, timemodule.c:floatsleep() calls select() on platforms that support it. On Linux, select() with a timeout has an unfortunate

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

2014-04-18 Thread Yury Selivanov
Changes by Yury Selivanov yselivanov...@gmail.com: -- nosy: +haypo, yselivanov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21302 ___ ___

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

2014-04-18 Thread Shankar Unni
Shankar Unni added the comment: I'm working on a patch, but I noticed a similar issue in Condition.wait(), which also keeps re-evaluating the remaining sleep time based on the current kernel clock, with similar effects. I'll try to address both issues, or we could open a separate bug for the