Python object three elements:
Identity (value): Address that corresponds to memory, non-modifiable
Type: Non-modifiable
Value (values):
Mutable: Can modify
Immutable: cannot be modified
Reference count
GC will actually reclaim the allocated memory when the reference count is 0
>>> def f ():
... pass
...
>>> ID (f)
139655884671288
>>> fa=f
>>> ID (FA)
139655884671288
>>> del FA
>>> del F
ID ()
Returns the memory address of an object
Used to determine if a memory object is the same
Integral type slow-section pool (0-1000)
1. For a certain range of integers, Python is allocated in memory in advance
2. You can modify the scope of the buffer pool by modifying the source code to recompile python
3. Will not be recycled
Integral type at the same address:
>>> a=1
>>> b=1
>>> ID (a)
19419960
>>> ID (b)
19419960
Class object is not in an address
>>> class A:
... pass
...
>>> C=a ()
>>> D=a ()
>>> ID (c)
140100598572888
>>> ID (d)
140100598572960
Is statement:
To determine if two variables are pointing to the same stored object
Python Learning Notes Basics