>>> A = 2.5
>>> B = 2.5
>>> C = b
>>> A is C
False
>>> A = 2
>>> B = 2
>>> C = b
>>> A is C
True
When you use the IS function to print a,b are assigned values of 2.5 and 2 respectively, found that:
>>> A = 2
>>> B = 2
>>> ID (a)
21132060
>>> ID (b)
21132060
>>> A = 2.5
>>> B = 2.5
>>> ID (a)
19622112
>>> ID (b)
29321464
When the a,b is 2, the ID is the same, and the 2.5 is the same, and this happens in string strings, that is, when very short a,b are assigned a short string, their ID values are the same, while the very long does not;
Check out the following articles:
Http://stackoverflow.com/questions/4293408/ids-of-immutable-types
Http://stackoverflow.com/questions/3402679/identifying-objects-why-does-the-returned-value-from-id-change
After that, we get a simple conclusion: The interpreter does a little bit of optimization on a small int and a very short string, assigning only one object and giving them IDs.