New submission from Alex Willmer <a...@moreati.org.uk>:

I believe the documentation for time.monotonic() and time.perf_counter() could 
be misleading. Taken literally they could imply that given

delta = 0.1
a = time.monotonic()
b = time.monotonic()
c = time.monotonic()

the comparisons `b - a < delta`, and `c - b < delta` are valid; but `c - a < 
delta` is not valid.

I believe that `c - a < delta` is a valid comparison, and that what the 
documentation means to say is "only the difference between the results of 
*subsequent* calls is valid."

The exact wording (present since the functions were added in 
https://hg.python.org/cpython/rev/376ce937823c)

> The reference point of the returned value is undefined, so that only
> the difference between the results of consecutive calls is valid.

If there is agreement I'll submit a PR.

----------
assignee: docs@python
components: Documentation
messages: 388133
nosy: Alex.Willmer, docs@python
priority: normal
severity: normal
status: open
title: time.monotonic(): Docs imply comparing call N and call N+M is invalid 
for M>1
versions: Python 3.6, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43407>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to