[issue36592] is behave different for integers in 3.6 and 3.7

Shane report at bugs.python.org
Wed Apr 10 20:06:11 EDT 2019


Shane <shanesmith4 at gmail.com> added the comment:

This is the sort of thing that makes me avoid "is" in favor of "==" for most applications.  Understanding when two objects point to the same memory requires a deeper understanding of the underlying code than I usually want to delve into.

Anyway, I find it interesting that for 3.7.3:
>>> a, b = 256, 256
>>> a is b
True

>>> a, b = 257, 257
>>> a is b
False


So 2**8 is a magic number, for whatever reason.  I'll be sticking with "=="...

----------
nosy: +Shane Smith -eric.smith
type: behavior -> 

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36592>
_______________________________________


More information about the Python-bugs-list mailing list