Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 03a0708

Browse files
committed
clarify that time.perf_counter cannot go backwards
I'm not completely sure about this, but it seems to me this counter is *also* designed to avoid jumping backwards on (say) daylight saving or clock changes. It's kind of hinted to in the current description, but reading PEP 418 it's very clear that it's part of the intention, as it falls back to time.monotonic() apart from on `nt`.
1 parent 1e5719a commit 03a0708

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Doc/library/time.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ Functions
314314
clock with the highest available resolution to measure a short duration. It
315315
does include time elapsed during sleep and is system-wide. The reference
316316
point of the returned value is undefined, so that only the difference between
317-
the results of two calls is valid.
317+
the results of two calls is valid. This counter, like :func:`monotonic`, cannot
318+
go backwards.
318319

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

0 commit comments

Comments
 (0)