[docs] Bugs in Python a,b=-6,-6

Julien Palard julien at palard.fr
Tue May 21 08:55:34 EDT 2019

Hi Benedic,

the id function returns an "identity of an object.", which is implementation dependent. In cpython it's the memory address, that's why it's huge numbers.

Also cpython can (and do) reuses some integers (from -5 and 256, but it's an implementation detail, this could change).

So -5 is always the same object in memory, but there can be two distinct -6 in memory, in the current implementation of cpython.

that's why id(-5) is always the same and id(-6) can vary in the same run.

This does not change anything, from a semantic point of view, as long as you're not comparing integers by using the id() or the is keyword, which you should not.

Julien Palard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20190521/12fb113c/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 17701 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/docs/attachments/20190521/12fb113c/attachment-0001.png>

More information about the docs mailing list