Python: Internal Integer Object Array
-5 to 256
Aug 27, 2017 · 1 min read
Python maintains an internal integer object array for integers between -5 and 256. Which explains why the comparison c is d below evaluates to False:
>>> a = 200 + 56
>>> b = 256
>>> c = 200 + 57
>>> d = 257
>>> a == b
True
>>> a is b
True
>>> c == d
True
>>> c is d
Falseis compared identities of objects, or their memory addresses. == compared numerical equality of objects.
