This is a series question about the cache mechanism of Python.
Firstly, I read Why (0-6) is -6 = False? to find there's something called pool of integer objects in Python, then I tried some other cases and found a phenomenon out of my understanding
In : a = 257; b = 257; id(a) == id(b)
Out: False
In : a, b = 257, 257; id(a) == id(b)
Out: True
In : a, b = (1,), (1,); id(a) == id(b)
Out: False
As the answer to that question mentioned, 257 is not in the range of small integer, so there should be a new object when you assigned a new variable with the value of 257, but a,b = 257, 257
showed True
. So I was assuming this kind of assigning method would assign them two same IDs at an initializing period, but the third case proved this assumption wrong.
Could you please explain why this way of assigning has different behaviors with non-cached integers(not in [-5,256]) and tuples?