weakref.WeakKeyDictionary.iterkeyrefs

WeakKeyDictionary.iterkeyrefs()[source]

Return an iterator that yields the weak references to the keys.

The references are not guaranteed to be ‘live’ at the time they are used, so the result of calling the references needs to be checked before being used. This can be used to avoid creating references that will cause the garbage collector to keep the keys around longer than needed.