weakref.WeakValueDictionary()
weakref.WeakValueDictionary() is a Python function in the Weakref Module category. A dictionary that holds weak references to its values. The syntax is weakref.WeakValueDictionary(). Returns: WeakValueDictionary object. A typical example: d = weakref.WeakValueDictionary()
d["key"] = Obj()
# Object can be garbage collected even if in dict. A close sibling is weakref.ref(), which creates a weak reference object. Call .deref() to get the object or None if collected. A close sibling is weakref.proxy(), which creates a weak reference proxy that acts like the original object. A close sibling is weakref.WeakKeyDictionary(), which a dictionary that holds weak references to its keys. A close sibling is weakref.WeakSet(), which a set that holds weak references to its elements. More about this category: Weak references — ref, proxy, WeakValueDictionary, WeakSet. Related Weakref Module entries: weakref.ref(), weakref.proxy(), weakref.WeakKeyDictionary(), weakref.WeakSet(), weakref.finalize(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.