Shane added the comment:
Well, then I guess that explains it! Still, like I said, I tend to shy away
from features that require such a deep understanding of the implementation in
order to avoid "gotchas". "is" does have its uses, but for me they very very
rarely come up.
--
Geraldo Xexeo added the comment:
"So 2**8 is a magic number, for whatever reason."
Actually, this is true. Accordingly to
https://rushter.com/blog/python-integer-implementation/
"Optimization of commonly-used integers
Small integer objects in a range of -5 to 256 are always pre-allocated
Shane 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
Eric V. Smith added the comment:
Python makes no guarantee as to whether an identity test on integers would
return True or False. You should not depend on the behavior in any particular
version.
--
nosy: +eric.smith
resolution: -> not a bug
stage: -> resolved
status: open ->
New submission from Geraldo Xexeo :
# When you run the program:
a,b=300,300
print(a is b)
#you get different results in 3.6 (True) and 3.7 (False)
--
components: Interpreter Core
files: testisbehavior.py
messages: 339900
nosy: Geraldo.Xexeo
priority: normal
severity: normal
status: