Identity comparison returning ‘True’ for objects which are not ‘interned’

  comparison-operators, object, python, python-3.x

I am using IDLE Shell 3.10

I have written following code to compare identity of two objects.

print('n Compare object identity of objects which are not interned')
x1 = 258656565
y1 = 258656565
print('{0} is {1}'.format(x1, y1), x1 is y1)

I am getting the output as True

As per my understanding the objects x1 and y1 don’t fall in the range -5 to 256 and are not interned. That is why, comparing the identity should return False

Source: Python Questions

LEAVE A COMMENT