[issue4638] 1 is 1 is allways true while 1.0 is 1.0 may sometimes be true

Tim Peters report at bugs.python.org
Fri Dec 12 02:54:57 CET 2008


Tim Peters <tim.peters at gmail.com> added the comment:

"is" is for testing object identity, not numeric equality.  That "1 is
1" is always true is simply an implementation detail common to all
recent versions of CPython, due to CPython caching "very small" integer
objects.  The language definition neither requires nor forbids this, so
any program relying on it is in error.  Likewise any program relying on
"1.0 is 1.0" being false is also in error.

----------
nosy: +tim_one

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4638>
_______________________________________


More information about the Python-bugs-list mailing list