I understand what's going on here wrt references:
>>> x = 5
>>> y = x
>>> id(x)
8729216
>>> id(y)
8729216
I also understand that with integers between -5 and 256, the Python interpreter has initialized an integer block ahead of time because of their frequency of use, so I expect the following:
>>> x = 5
>>> y = 5
>>> id(x)
8729216
>>> id(y)
8729216
What I wasn't sure about was what would happen if an integer larger than 256 was created, so I typed some code into the interpreter:
>>> x = 1234567890
>>> y = 1234567890
>>> id(x)
140542533943248
>>> id(y)
140542533943088
OK, the id values are different so two different integer objects were allocated, they just happen to have the same value.
I thought that was it, but then I ran the same bit of code in a script and the id values were the same:
x = 1234567890
y = 1234567890
print(id(x))
print(id(y))
Values printed to the screen:
139663862951888
139663862951888
Huh? Here they are referencing the same integer object. What gives?