Issue 26511: Add link to id() built-in in comparison operator documentation for "is" (original) (raw)

Created on 2016-03-08 15:39 by Mike Vertolli, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue_26511.patch thomir,2016-09-11 23:17 review
Messages (8)
msg261364 - (view) Author: Mike Vertolli (Mike Vertolli) Date: 2016-03-08 15:39
Here's the doc: https://docs.python.org/2/reference/expressions.html#is It would be great if this line: "The operators is and is not test for object identity: x is y is true if and only if x and y are the same object. x is not y yields the inverse truth value.[7]" Could link to the id() builtin doc: https://docs.python.org/2/library/functions.html#id One way to rephrase this could be: "The operators is and is not test for object identity: x is y is true if and only if x and y are the same object or id(x) == id(y). x is not y yields the inverse truth value.[7]" And, the id's can be hyperlinks. It would also be nice if that reference linked to a page on integer caching in Python.
msg261620 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-03-11 23:58
There is not 'integer caching in Python'. This is strictly an implementation feature of CPython, and any other implementation that does similarly. "or id(x) == id(y)" should be "(id(x) == id(y))" as the addition is an alternate wording, not an alternate condition. I am not sure that this will always be helpful.
msg261633 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-03-12 02:49
Please don’t use nested brackets like that in English text. Try to rewrite the sentence without brackets (e.g. use a comma or say “This is equivalent to”) [or use a different kind of bracket if you really must (to make the nesting clearer)].
msg261678 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-03-13 07:12
I agree with the OP that is would be useful to link to id(). I also concur with Terry that integer caching is to remain an undocumented implementation specific detail (just an optimization). Also, Martin is correct that the proposed wording doesn't read well.
msg275884 - (view) Author: Thomi Richards (thomir) * Date: 2016-09-11 23:17
Attached patch for master branch.
msg275886 - (view) Author: Thomi Richards (thomir) * Date: 2016-09-11 23:34
The attached patch applies to 3.5, but not 2.7. If you're happy with it, I can work up a version for 2.7 as well.
msg275899 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-12 00:24
New changeset f38b831cb6b9 by Raymond Hettinger in branch '3.5': Issue #26511: Reference the id() function in the 'is' and 'is not' docs https://hg.python.org/cpython/rev/f38b831cb6b9
msg275900 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-09-12 00:25
Thanks for the patch. Not need to go back to 2.7. This is really minor.
History
Date User Action Args
2022-04-11 14:58:28 admin set github: 70698
2016-09-12 00:25:22 rhettinger set status: open -> closedresolution: fixedmessages: +
2016-09-12 00:24:22 python-dev set nosy: + python-devmessages: +
2016-09-11 23:34:59 thomir set messages: +
2016-09-11 23:17:23 thomir set files: + issue_26511.patchnosy: + thomirmessages: + keywords: + patch
2016-03-13 07:17:06 ezio.melotti set keywords: + easynosy: + ezio.melotti
2016-03-13 07:12:50 rhettinger set assignee: docs@python -> rhettingermessages: + nosy: + rhettinger
2016-03-12 02:49:22 martin.panter set nosy: + martin.pantermessages: +
2016-03-11 23:58:27 terry.reedy set versions: + Python 3.5, Python 3.6nosy: + terry.reedymessages: + stage: needs patch
2016-03-08 15:39:21 Mike Vertolli create