Lines Matching full:weak
1 :mod:`weakref` --- Weak references
5 :synopsis: Support for weak references and weak dictionaries.
18 The :mod:`weakref` module allows the Python programmer to create :dfn:`weak
25 by a weak reference.
27 A weak reference to an object is not enough to keep the object alive: when the
28 only remaining references to a referent are weak references,
30 for something else. A primary use for weak references is to implement caches or
39 the :mod:`weakref` module are an alternative, using weak references to construct
43 image object are the weak references held by weak mappings, garbage collection
44 can reclaim the object, and its corresponding entries in weak mappings are
47 :class:`WeakKeyDictionary` and :class:`WeakValueDictionary` use weak references
48 in their implementation, setting up callback functions on the weak references
49 that notify the weak dictionaries when a key or value has been reclaimed by
50 garbage collection. Most programs should find that using one of these weak
52 own weak references directly. The low-level machinery used by the weak
69 support weak references but can add support through subclassing::
74 obj = Dict(red=1, green=2, blue=3) # this object is weak referenceable
79 weak references even when subclassed.
81 Extension types can easily be made to support weak references; see
87 Return a weak reference to *object*. The original object can be retrieved by
92 about to be finalized; the weak reference object will be passed as the only
95 It is allowable for many weak references to be constructed for the same object.
96 Callbacks registered for each weak reference will be called from the most
103 Weak references are :term:`hashable` if the *object* is hashable. They will maintain
108 Weak references support tests for equality, but not ordering. If the referents
120 Return a proxy to *object* which uses a weak reference. This supports use of
122 with weak reference objects. The returned object will have a type of either
132 Return the number of weak references and proxies which refer to *object*.
137 Return a list of all weak reference and proxy objects which refer to *object*.
166 Return an iterable of the weak references to the keys.
173 Return a list of weak references to the keys.
198 Return an iterable of the weak references to the values.
205 Return a list of weak references to the values.
212 Set class that keeps weak references to its elements. An element will be
220 The type object for weak references objects.
248 :pep:`205` - Weak References
255 Weak Reference Objects
258 Weak reference objects have no attributes or methods, but do allow the referent
278 Testing that a weak reference object is still live should be done using the
282 # r is a weak reference object
292 applications; another thread can cause a weak reference to become invalidated
293 before the weak reference is called; the idiom shown above is safe in threaded