[issue43407] time.monotonic(): Docs imply comparing call N and call N+M is invalid for M>1

2021-03-05 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.10 -Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43407] time.monotonic(): Docs imply comparing call N and call N+M is invalid for M>1

2021-03-05 Thread miss-islington


miss-islington  added the comment:


New changeset 65f3a0d20c8198443c5c6cb44410114fe8c4bf4e by Miss Islington (bot) 
in branch '3.9':
bpo-43407: Clarify comparisons of time.monotonic() et al results (GH-24757)
https://github.com/python/cpython/commit/65f3a0d20c8198443c5c6cb44410114fe8c4bf4e


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43407] time.monotonic(): Docs imply comparing call N and call N+M is invalid for M>1

2021-03-05 Thread miss-islington


miss-islington  added the comment:


New changeset e12a9e2f62bea8ddc755e373f17adfbb2740b0b1 by Miss Islington (bot) 
in branch '3.8':
bpo-43407: Clarify comparisons of time.monotonic() et al results (GH-24757)
https://github.com/python/cpython/commit/e12a9e2f62bea8ddc755e373f17adfbb2740b0b1


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43407] time.monotonic(): Docs imply comparing call N and call N+M is invalid for M>1

2021-03-05 Thread miss-islington


Change by miss-islington :


--
pull_requests: +23537
pull_request: https://github.com/python/cpython/pull/24769

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43407] time.monotonic(): Docs imply comparing call N and call N+M is invalid for M>1

2021-03-05 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 2.0 -> 3.0
pull_requests: +23536
pull_request: https://github.com/python/cpython/pull/24768

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43407] time.monotonic(): Docs imply comparing call N and call N+M is invalid for M>1

2021-03-05 Thread Terry J. Reedy


Terry J. Reedy  added the comment:


New changeset ff5f05934db241dfafc604989b2de3487b09ca82 by Alex Willmer in 
branch 'master':
bpo-43407: Clarify comparisons of time.monotonic() et al results (GH-24757)
https://github.com/python/cpython/commit/ff5f05934db241dfafc604989b2de3487b09ca82


--
nosy: +terry.reedy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43407] time.monotonic(): Docs imply comparing call N and call N+M is invalid for M>1

2021-03-04 Thread Alex Willmer


Change by Alex Willmer :


--
keywords: +patch
pull_requests: +23528
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24757

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43407] time.monotonic(): Docs imply comparing call N and call N+M is invalid for M>1

2021-03-04 Thread Alex Willmer


Alex Willmer  added the comment:

Discussion from #python IRC

[21:51]  Given `a=time.monotonic(); b=time.monotonic(); 
c=time.monotonic()` is `c-a < delta` a valid comparison? Until this evening I 
thought so, but I've just read 
https://docs.python.org/3/library/time.html#time.monotonic and the wording it 
uses is "only the difference between the results of consecutive calls is valid" 
implying `b-a < delta` is valid, or `c-b < delta`; but not `c-a < delta`. Am I 
understanding the wording correctly?
[21:52]  IOW is it literally only call n, and n+1. or n, and n+m?
[21:53]  moreati, I think "consecutive" is incorrect there, based on 
the rest of that sentence.
[21:57]  moreati SnoopJ yes, I agree, the consecutive wording has 
tripped me up when I first started using monotonic. I think there's an 
understated transitive property that allows a to c comparisons just fine.
[21:58]  jarthur, yea, it would be deeply weird if `b-a` and `c-b` were 
meaningful deltas, but `c-a` was not
[21:59]  re time.monotonic() the only reason I could of for the 
literal interpretation of the wording is an overflow, or integer wraparound 
corner case
[22:00]  weirdly, the CPython doc uses the same language
[22:02]  I actually ended up looking at the monotonic code a while 
back, and at least back then the wraparound case is really hard to reach, maybe 
possible on Windows if you haven't called it in a while. Either way, there was 
nothing in the Linux/glibc or Windows calls used that would have made the 
wraparound/overflow case apply to skipped evaluation of a middle observation 
more than it would consecutive observations.
...
[22:06]  moreati, looks like this language was added when the function 
was, and I guess maybe nobody's ever raised this complaint about the wording: 
https://hg.python.org/cpython/rev/376ce937823c
[22:07]  nice catch :)
...
[22:22]  FTR https://bugs.python.org/issue43407
[22:28]  moreati, I would recommend just submitting the PR, since it's 
docs.
[22:28]  ok
[22:28]  but I think the best wording would be something like "only the 
difference between two calls of this function is meaningful"
[22:30]  agreed, subsequent is a $5 word in a 50c requirement. May I 
quote our conversation in the ticket? Ditto jarthur
[22:30]  absolutely
[22:30]  yep
[22:30]  ty
[22:30]  but yea, just open a PR, that way you need a single pass from 
someone with authority here rather than two ;)
[22:31]  >Never use a long word where a short one will do.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43407] time.monotonic(): Docs imply comparing call N and call N+M is invalid for M>1

2021-03-04 Thread Alex Willmer


New submission from Alex Willmer :

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com