Oct-24-2019, 09:35 AM
(This post was last modified: Oct-24-2019, 09:35 AM by Gribouillis.)
There is an object in memory containing the value 5. Concretely it is a sequence of bytes in memory and the value 5 is written somewhere in binary form on these bytes. The object receives a unique ID when the memory for this object is allocated. Normally python uses the address in memory as the object's ID, which is an easy way to guarantee that different objects have different IDs. The only thing to know is that once the object has been deallocated, the same address, ID can be reused for another object. Live example:
>>> x = [] >>> id(x) 140240781096328 >>> x = [] >>> id(x) 140240781067400 >>> x = [] >>> id(x) 140240781096328