Skip to content

Commit fc4474e

Browse files
corona10ambv
andauthored
bpo-45429: Merge whatsnew about time.sleep (GH-29589)
Co-authored-by: Łukasz Langa <[email protected]>
1 parent abc0d75 commit fc4474e

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

Doc/library/time.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -362,17 +362,17 @@ Functions
362362
On Windows, if *secs* is zero, the thread relinquishes the remainder of its
363363
time slice to any other thread that is ready to run. If there are no other
364364
threads ready to run, the function returns immediately, and the thread
365-
continues execution.
365+
continues execution. On Windows 8.1 and newer the implementation uses
366+
a `high-resolution timer
367+
<https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/high-resolution-timers>`_
368+
which provides resolution of 100 nanoseconds. If *secs* is zero, ``Sleep(0)`` is used.
366369

367370
Unix implementation:
368371

369372
* Use ``clock_nanosleep()`` if available (resolution: 1 nanosecond);
370373
* Or use ``nanosleep()`` if available (resolution: 1 nanosecond);
371374
* Or use ``select()`` (resolution: 1 microsecond).
372375

373-
On Windows, a waitable timer is used (resolution: 100 nanosecond). If *secs* is
374-
zero, ``Sleep(0)`` is used.
375-
376376
.. versionchanged:: 3.11
377377
On Unix, the ``clock_nanosleep()`` and ``nanosleep()`` functions are now
378378
used if available. On Windows, a waitable timer is now used.

Doc/whatsnew/3.11.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ threading
269269
by system clock changes.
270270
(Contributed by Victor Stinner in :issue:`41710`.)
271271

272+
272273
time
273274
----
274275

@@ -278,14 +279,13 @@ time
278279
of 1 microsecond (10\ :sup:`-6` seconds).
279280
(Contributed by Benjamin Szőke and Victor Stinner in :issue:`21302`.)
280281

281-
* On Windows, :func:`time.sleep` now uses a waitable timer which has a
282-
resolution of 100 nanoseconds (10\ :sup:`-7` seconds). Previously, it had
283-
a resolution of 1 millisecond (10\ :sup:`-3` seconds).
284-
(Contributed by Benjamin Szőke and Victor Stinner in :issue:`21302`.)
282+
* On Windows 8.1 and newer, :func:`time.sleep` now uses a waitable timer based
283+
on `high-resolution timers
284+
<https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/high-resolution-timers>`_
285+
which has a resolution of 100 nanoseconds (10\ :sup:`-7` seconds). Previously,
286+
it had a resolution of 1 millisecond (10\ :sup:`-3` seconds).
287+
(Contributed by Benjamin Szőke, Dong-hee Na, Eryk Sun and Victor Stinner in :issue:`21302` and :issue:`45429`.)
285288

286-
* On Windows, :func:`time.sleep` now uses a waitable timer which supports high-resolution timers.
287-
In Python 3.10, the best resolution was 1 ms, from Python 3.11 it's now smaller than 1 ms.
288-
(Contributed by Dong-hee Na and Eryk Sun in :issue:`45429`.)
289289

290290
unicodedata
291291
-----------

0 commit comments

Comments
 (0)