|Topic was automatically imported from the old Question2Answer platform.
I want to store a bunch of weak references to objects in a set-like datastructure. I am thinking of doing something like the following, where
set is a dictionary:
set[obj.get_instance_id()] = weakref( obj )
I think this will work, but there isn’t too much documentation of
get_instance_id. It sounds straightforward, but I want to make sure there are no unspoken caveats. Will the above always result in only one weakref per object added to the list?
Also, I will be looping over the values more than looking them up. Would it be better to use an array, then?