As I mentioned in my comment on @Martjin Pieters answer, id() inline can be good enough for your needs. id(obj) returns id for any object in the system that is unique during access (in fact, in some interpreters it is literally the memory address of the object). If your objects are not destroyed often, but your identifier links must remain valid even after destruction, id() should work for your unique needs.
From the docs:
[The value returned by id ()] is an integer (or long integer) that is guaranteed to be unique and constant for this object during its lifetime. Two objects with non-overlapping lifetimes can have the same id () value.
source share