I'm aware of the CPython implementation that holds a small integer cache in the [-5, 256] range, so I understand that a=2 and b=2 will refer to the same memory address (thus causing a is b to return true. Also, if I store a number higher than 256 I should obtain different memory addresses, as follows:
>>> x=500
>>> y=500
>>> x is y
False
However, this is where I get confused:
>>> x,y=500,500
>>> x is y
True
Can anyone explain why this happens, or at least what's different when storing values separately as opposed to storing them both at once?