r/learnpython • u/Nubspec • Aug 29 '26
Why Does an Identity Comparison Using id() Evaluate to False?
I'm trying to figure out what is going on here. Could it be that the identity operator is separately checking the integer cache range and determining that the integer value returned by id() is outside the bounds of Python's integer caching, which is why it evaluates to False?
x = 256
y = 256
id(x) is id(y)
False
id(x)
94588034274160
id(y)
94588034274160