apparently small ints are Special
>>> a = 256
>>> b = 256
>>> a == b
True
>>> a is b
True
>>> a = 257
>>> b = 257
>>> a == b
True
>>> a is b
False
apparently small ints are Special
>>> a = 256
>>> b = 256
>>> a == b
True
>>> a is b
True
>>> a = 257
>>> b = 257
>>> a == b
True
>>> a is b
False
that sort of even makes sense maybe. this does not:
>>> a = -5
>>> b = -5
>>> a is b
True
>>> a = -6
>>> b = -6
>>> a is b
False
>>> a = -6; b = -6
>>> a is b
True
Does sort of: it’s caching immutable small int objects and handing you back a reference to an existing one rather than creating loads of separate objects for every “1”. Then it pre-fills the cache with -5..255 which are presumably the most common.
On second thoughts, that isn’t actually supported by the above example. Maybe it doesn’t make sense.
transparency not python strong suit rly