From f1d7dfd5f85bfc963bf20e95f3c1dd30638ae0de Mon Sep 17 00:00:00 2001 From: Stefan <93658221+dbstf@users.noreply.github.com> Date: Tue, 12 Nov 2024 14:25:30 +0100 Subject: [PATCH] Fixup Docu time.rst - On Windows, the .time function now uses GetSystemTimePreciseAsFileTime() [--> 1 microsecond resolution] instead of GetSystemTimeAsFileTime() [--> 15.625 millisecond resolution]. - On Windows The .monotonic functions now use the same clock as the .perf_counter functions, not vice versa. The .perf_counter functions previously already used QueryPerformanceCounter() + QueryPerformanceFrequency() [--> 1 microsecond resolution], whereas the .monotonic functions used GetTickCount64() [--> 15.625 millisecond resolution]. --- Doc/library/time.rst | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/Doc/library/time.rst b/Doc/library/time.rst index 6265c2214eaa0d..9e38d2a1355cb7 100644 --- a/Doc/library/time.rst +++ b/Doc/library/time.rst @@ -299,6 +299,11 @@ Functions Use :func:`monotonic_ns` to avoid the precision loss caused by the :class:`float` type. + .. 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. + .. versionadded:: 3.3 .. versionchanged:: 3.5 @@ -307,6 +312,11 @@ 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` + now call ``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 @@ -314,6 +324,9 @@ Functions .. versionadded:: 3.7 + .. versionchanged:: 3.13 + Use the same clock as :func:`time.perf_counter`. + .. function:: perf_counter() -> float .. index:: @@ -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. @@ -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. @@ -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 + 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