weakref.WeakSet()
weakref.WeakSet() is a Python function in the Weakref Module category. A set that holds weak references to its elements. The syntax is weakref.WeakSet(). Returns: WeakSet object. A typical example: s = weakref.WeakSet()
s.add(obj)
# obj can be collected. 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.WeakValueDictionary(), which a dictionary that holds weak references to its values. A close sibling is weakref.WeakKeyDictionary(), which a dictionary that holds weak references to its keys. More about this category: Weak references — ref, proxy, WeakValueDictionary, WeakSet. Related Weakref Module entries: weakref.ref(), weakref.proxy(), weakref.WeakValueDictionary(), weakref.WeakKeyDictionary(), weakref.finalize(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.