Skip to content

Commit ff5f059

Browse files
authored
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.
1 parent 8e1b406 commit ff5f059

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
@@ -277,7 +277,7 @@ Functions
277277
Return the value (in fractional seconds) of a monotonic clock, i.e. a clock
278278
that cannot go backwards. The clock is not affected by system clock updates.
279279
The reference point of the returned value is undefined, so that only the
280-
difference between the results of consecutive calls is valid.
280+
difference between the results of two calls is valid.
281281

282282
Use :func:`monotonic_ns` to avoid the precision loss caused by the
283283
:class:`float` type.
@@ -306,7 +306,7 @@ Functions
306306
clock with the highest available resolution to measure a short duration. It
307307
does include time elapsed during sleep and is system-wide. The reference
308308
point of the returned value is undefined, so that only the difference between
309-
the results of consecutive calls is valid.
309+
the results of two calls is valid.
310310

311311
Use :func:`perf_counter_ns` to avoid the precision loss caused by the
312312
:class:`float` type.
@@ -334,7 +334,7 @@ Functions
334334
CPU time of the current process. It does not include time elapsed during
335335
sleep. It is process-wide by definition. The reference point of the
336336
returned value is undefined, so that only the difference between the results
337-
of consecutive calls is valid.
337+
of two calls is valid.
338338

339339
Use :func:`process_time_ns` to avoid the precision loss caused by the
340340
:class:`float` type.
@@ -626,7 +626,7 @@ Functions
626626
CPU time of the current thread. It does not include time elapsed during
627627
sleep. It is thread-specific by definition. The reference point of the
628628
returned value is undefined, so that only the difference between the results
629-
of consecutive calls in the same thread is valid.
629+
of two calls in the same thread is valid.
630630

631631
Use :func:`thread_time_ns` to avoid the precision loss caused by the
632632
:class:`float` type.
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)