This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add link to id() built-in in comparison operator documentation for "is"
Type: enhancement Stage: needs patch
Components: Documentation Versions: Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: Mike Vertolli, docs@python, ezio.melotti, martin.panter, python-dev, rhettinger, terry.reedy, thomir
Priority: normal Keywords: easy, patch

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:28adminsetgithub: 70698
2016-09-12 00:25:22rhettingersetstatus: open -> closed
resolution: fixed
messages: + msg275900
2016-09-12 00:24:22python-devsetnosy: + python-dev
messages: + msg275899
2016-09-11 23:34:59thomirsetmessages: + msg275886
2016-09-11 23:17:23thomirsetfiles: + issue_26511.patch

nosy: + thomir
messages: + msg275884

keywords: + patch
2016-03-13 07:17:06ezio.melottisetkeywords: + easy
nosy: + ezio.melotti
2016-03-13 07:12:50rhettingersetassignee: docs@python -> rhettinger

messages: + msg261678
nosy: + rhettinger
2016-03-12 02:49:22martin.pantersetnosy: + martin.panter
messages: + msg261633
2016-03-11 23:58:27terry.reedysetversions: + Python 3.5, Python 3.6
nosy: + terry.reedy

messages: + msg261620

stage: needs patch
2016-03-08 15:39:21Mike Vertollicreate