variables and identity operations
ID () Definition: The function is used to get the memory address of the object.
To name a list:
name = ' Tangni '
ID (name)
Output
(56156880)
1.1 Two variable names one value column:
Since ' Tangni ' is a simple string, the Python interpreter has been optimized, with only one ' Tangni ' in memory, name1 and name2 all pointing to the same memory address.
name1 = ' Tangni '
name2 = ' Tangni '
name1_id = ID (name1)
name2_id = ID (name2)
Print (name1_id,name2_id)
Output
(56156880 56156880)
1.2 If it is a long string there is no optimization mechanism!
>>> a = ' This is a very long sentence ' >>> b = ' This is a very long sentence ' >>> id (A4394464720>>> id4394464640
1.3 column in the range:
A = 256
b = 256
ID (a)
1502186480
ID (b)
1502186480
Beyond the range:
A = 257
b = 257
ID (a)
55420240
ID (b)
55419312
Identity operations
Chapter II python basic data types