8000 gh-126745: Fixup Docu time.rst by dbstf · Pull Request #126744 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-126745: Fixup Docu time.rst #126744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
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
29 changes: 19 additions & 10 deletions Doc/library/time.rst
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@ Functions
Use :func:`monotonic_ns` to avoid the precision loss caused by the
:class:`float` type.

10000 .. impl-detail::

On CPython, use the same clock as :func:`time.perf_counter` and is a
monotonic clock, i.e. a clock that cannot go backwards.
Copy link
Member

Choose a reason for hiding this comment

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

This makes more sense under perf_counter were it was. All monotonic function should always be monotonic, by definition.


.. versionadded:: 3.3

.. versionchanged:: 3.5
Expand All @@ -307,13 +312,21 @@ Functions
.. versionchanged:: 3.10
On macOS, the function is now system-wide.

.. versionchanged:: 3.13
Use the same clock as :func:`time.perf_counter`. On Windows, :func:`monotonic`

This comment was marked as resolved.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Use the same clock as :func:`time.perf_counter`. On Windows, :func:`monotonic`
The function now uses the same clock as :func:`time.perf_counter`. On Windows, :func:`monotonic`

now call ``QueryPerformanceCounter()`` which has a resolution of 1 microsecond,
Comment on lines +316 to +317
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Use the same clock as :func:`time.perf_counter`. On Windows, :func:`monotonic`
now call ``QueryPerformanceCounter()`` which has a resolution of 1 microsecond,
Use the same clock as :func:`time.perf_counter`. On Windows, :func:`monotonic`
now calls ``QueryPerformanceCounter()`` which has a resolution of 1 microsecond,

instead of the ``GetTickCount64()`` clock like in previous versions, which has
a resolution of 15.625 milliseconds.

.. function:: monotonic_ns() -> int

Similar to :func:`monotonic`, but return time as nanoseconds.

.. versionadded:: 3.7

.. versionchanged:: 3.13
Use the same clock as :func:`time.perf_counter`.

.. function:: perf_counter() -> float

.. index::
Expand All @@ -325,11 +338,6 @@ Functions
point of the returned value is undefined, so that only the difference between
the results of two calls is valid.

.. impl-detail::

On CPython, use the same clock as :func:`time.monotonic` and is a
monotonic clock, i.e. a clock that cannot go backwards.

Use :func:`perf_counter_ns` to avoid the precision loss caused by the
:class:`float` type.

Expand All @@ -338,10 +346,6 @@ Functions
.. versionchanged:: 3.10
On Windows, the function is now system-wide.

.. versionchanged:: 3.13
Use the same clock as :func:`time.monotonic`.


.. function:: perf_counter_ns() -> int

Similar to :func:`perf_counter`, but return time as nanoseconds.
Expand Down Expand Up @@ -699,13 +703,18 @@ Functions

Clock:

* On Windows, call ``GetSystemTimeAsFileTime()``.
* On Windows, call ``GetSystemTimePreciseAsFileTime()``.
* Call ``clock_gettime(CLOCK_REALTIME)`` if available.
* Otherwise, call ``gettimeofday()``.

Use :func:`time_ns` to avoid the precision loss caused by the :class:`float`
type.

.. versionchanged:: 3.13
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.. versionchanged:: 3.13
.. versionchanged:: 3.13

Suspect the mixed indentation is screwing it up

On Windows, :func:`.time` now uses the ``GetSystemTimePreciseAsFileTime()``
clock for a resolution of 1 microsecond, instead of the
``GetSystemTimeAsFileTime()`` clock which has a resolution of
15.625 milliseconds.

.. function:: time_ns() -> int

Expand Down
Loading
0