3. Python's basic type analysis and internal storage analysis of integer floating-point types

Insert picture description here
Insert picture description here
Insert picture description here
We find that the address of num has changed. Every time we change the value of the variable, it references a new address space.
Let's look at this memory structure:
Insert picture description here
a beginning num = 1 when, in fact, num which is stored an address, the address is assumed to be 1001, corresponding to a piece of memory space, the value of the 1001 memory storage space inside is 1;
when After we change num to 1.0, at this time, num stores another address 1002, which points to another float type memory space, and the value stored in it is 1.0.
When our num is equal to 1.0, the reference count of the address space of 1001 corresponding to the above num has actually been set to 0, because when num points to other objects, the reference count of this 1001 object will be reduced by 1, and it will change. If it becomes 0, the 1001 object will be released.

Insert picture description here

Insert picture description here

Guess you like

Origin blog.csdn.net/zhaopeng01zp/article/details/109234740