From 03a070838174c6099144dad931ea8536178e1b7f Mon Sep 17 00:00:00 2001 From: anarcat Date: Sun, 18 Feb 2024 16:08:04 -0500 Subject: [PATCH] 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`. --- Doc/library/time.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/library/time.rst b/Doc/library/time.rst index 2782a961363666..dedd4a7e8fc73d 100644 --- a/Doc/library/time.rst +++ b/Doc/library/time.rst @@ -314,7 +314,8 @@ Functions clock with the highest available resolution to measure a short duration. It does include time elapsed during sleep and is system-wide. The reference point of the returned value is undefined, so that only the difference between - the results of two calls is valid. + the results of two calls is valid. This counter, like :func:`monotonic`, cannot + go backwards. Use :func:`perf_counter_ns` to avoid the precision loss caused by the :class:`float` type.