Optimization mechanism in python (both 2.7 and 3.5):
Numbers between -5~257, if you use the first assignment method, then they still belong to the same memory.
But the test code I wrote on my local machine is as follows:
Result
#This is inconsistent with the above.
Then I tested it on the compiler on the Python official website and it was correct
I would like to ask what is the cause of this. . .
1. It is a py module file. In the same module, the same constant object is only allocated one storage unit
2. It is a python interpreter. This one has decimal optimization of -5~257