Skip to content

Commit 65f3a0d

Browse files
bpo-43407: Clarify comparisons of time.monotonic() et al results (GH-24757)
Previous wording implied that only the result of call N and N+1 could be meaningfully compared, whereas comparing call N and N+M is fine. (cherry picked from commit ff5f059) Co-authored-by: Alex Willmer <[email protected]>
1 parent 0dd4cb9 commit 65f3a0d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Doc/library/time.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ Functions
271271
Return the value (in fractional seconds) of a monotonic clock, i.e. a clock
272272
that cannot go backwards. The clock is not affected by system clock updates.
273273
The reference point of the returned value is undefined, so that only the
274-
difference between the results of consecutive calls is valid.
274+
difference between the results of two calls is valid.
275275

276276
.. versionadded:: 3.3
277277
.. versionchanged:: 3.5
@@ -293,7 +293,7 @@ Functions
293293
clock with the highest available resolution to measure a short duration. It
294294
does include time elapsed during sleep and is system-wide. The reference
295295
point of the returned value is undefined, so that only the difference between
296-
the results of consecutive calls is valid.
296+
the results of two calls is valid.
297297

298298
.. versionadded:: 3.3
299299

@@ -315,7 +315,7 @@ Functions
315315
CPU time of the current process. It does not include time elapsed during
316316
sleep. It is process-wide by definition. The reference point of the
317317
returned value is undefined, so that only the difference between the results
318-
of consecutive calls is valid.
318+
of two calls is valid.
319319

320320
.. versionadded:: 3.3
321321

@@ -593,7 +593,7 @@ Functions
593593
CPU time of the current thread. It does not include time elapsed during
594594
sleep. It is thread-specific by definition. The reference point of the
595595
returned value is undefined, so that only the difference between the results
596-
of consecutive calls in the same thread is valid.
596+
of two calls in the same thread is valid.
597597

598598
.. availability:: Windows, Linux, Unix systems supporting
599599
``CLOCK_THREAD_CPUTIME_ID``.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Clarified that a result from :func:`time.monotonic`,
2+
:func:`time.perf_counter`, :func:`time.process_time`, or
3+
:func:`time.thread_time` can be compared with the result from any following
4+
call to the same function - not just the next immediate call.

0 commit comments

Comments
 (0)