3 ms·
> the builtin id() function, which is just the memory address. This, crucially, is not guaranteed. Instead, id() is only guaranteed to give a unique integer v
by teddyh 6y ago
> the builtin id() function, which is just the memory address.
This, crucially, is not guaranteed. Instead, id() is only guaranteed to give a unique integer value for every object valid for the lifetime of that object. So if Python deallocated your first string object and allocated a new string object, Python could give the same id() for the new string object and this would be fine; this does not necessarily mean that the two string objects are the “same” object! In fact, since the objects do not share lifetimes, they cannot be said to be the same object!