Problems with Python3.6 int optimization mechanism, 64-bit machines (-5 to 257)
ringa_lee
ringa_lee 2017-05-18 10:54:54
0
1
770

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. . .

ringa_lee
ringa_lee

ringa_lee

reply all(1)
淡淡烟草味

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template