Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update docs
  • Loading branch information
picnixz committed Jan 3, 2025
commit 153b326ffd7aea805275b8f93f5909f103a74196
12 changes: 0 additions & 12 deletions Doc/library/time.rst
Original file line number Diff line number Diff line change
Expand Up @@ -397,18 +397,10 @@ Functions

.. rubric:: Unix implementation

If *secs* is zero, ``select()`` is used. Otherwise:

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

.. note::

To voluntarily relinquish the CPU, specify a read-time :ref:`scheduling
policy <os-scheduling-policy>` (see :manpage:`sched_yield(2)`) and use
:func:`os.sched_yield` instead.

.. audit-event:: time.sleep secs

.. versionchanged:: 3.5
Expand All @@ -423,10 +415,6 @@ Functions
.. versionchanged:: 3.13
Raises an auditing event.

.. versionchanged:: next
On Unix, ``time.sleep(0)`` always uses ``select()``, even if the
``clock_nanosleep()`` or ``nanosleep()`` functions are available.

.. index::
single: % (percent); datetime format

Expand Down
5 changes: 2 additions & 3 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,8 @@ Two new events are added: :monitoring-event:`BRANCH_LEFT` and
time
----

* Ensure that :func:`time.sleep(0) <time.sleep>` does not accumulate delays on
POSIX platforms. The implementation always uses :manpage:`select(2)` even if
the :manpage:`clock_nanosleep` or :manpage:`nanosleep` functions are present.
* Ensure that :func:`time.sleep(0) <time.sleep>` does not degrade over time
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose that you're referring to performance:

Suggested change
* Ensure that :func:`time.sleep(0) <time.sleep>` does not degrade over time
* Ensure that :func:`time.sleep(0) <time.sleep>` performance does not degrade over time

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on the resolution of this PR (namely, whether we eventually use select()), I'll amend the NEWS so I won't commit that suggestion for now.

on non-Windows platforms.
(Contributed by Bénédikt Tran in :gh:`125997`.)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Ensure that :func:`time.sleep(0) <time.sleep>` does not accumulate delays on
non-Windows platforms. Patch by Bénédikt Tran.
Ensure that :func:`time.sleep(0) <time.sleep>` does not degrade over time
on non-Windows platforms. Patch by Bénédikt Tran.