• Home
  • Raw
  • Download

Lines Matching refs:weak

5    :synopsis: Support for weak references and weak dictionaries.
16 The :mod:`weakref` module allows the Python programmer to create :dfn:`weak
23 by a weak reference.
25 A weak reference to an object is not enough to keep the object alive: when the
26 only remaining references to a referent are weak references,
28 for something else. However, until the object is actually destroyed the weak
31 A primary use for weak references is to implement caches or
40 the :mod:`weakref` module are an alternative, using weak references to construct
44 image object are the weak references held by weak mappings, garbage collection
45 can reclaim the object, and its corresponding entries in weak mappings are
48 :class:`WeakKeyDictionary` and :class:`WeakValueDictionary` use weak references
49 in their implementation, setting up callback functions on the weak references
50 that notify the weak dictionaries when a key or value has been reclaimed by
52 but keeps weak references to its elements, just like a
58 weak reference, since the module automatically ensures that the finalizer
61 Most programs should find that using one of these weak container types
63 create your own weak references directly. The low-level machinery is
76 support weak references but can add support through subclassing::
81 obj = Dict(red=1, green=2, blue=3) # this object is weak referenceable
85 Other built-in types such as :class:`tuple` and :class:`int` do not support weak
88 Extension types can easily be made to support weak references; see
91 When ``__slots__`` are defined for a given type, weak reference support is
98 Return a weak reference to *object*. The original object can be retrieved by
103 about to be finalized; the weak reference object will be passed as the only
106 It is allowable for many weak references to be constructed for the same object.
107 Callbacks registered for each weak reference will be called from the most
138 Return a proxy to *object* which uses a weak reference. This supports use of
140 with weak reference objects. The returned object will have a type of either
154 Return the number of weak references and proxies which refer to *object*.
159 Return a list of all weak reference and proxy objects which refer to *object*.
183 Return an iterable of the weak references to the keys.
201 Return an iterable of the weak references to the values.
206 Set class that keeps weak references to its elements. An element will be
212 A custom :class:`ref` subclass which simulates a weak reference to a bound
214 Since a bound method is ephemeral, a standard weak reference cannot keep
241 is garbage collected. Unlike an ordinary weak reference, a finalizer
253 from an object's :meth:`__del__` method or a weak reference's
304 The type object for weak references objects.
337 :attr:`ref.__callback__`. A weak reference object allows the referent to be
357 Testing that a weak reference object is still live should be done using the
361 # r is a weak reference object
371 applications; another thread can cause a weak reference to become invalidated
372 before the weak reference is called; the idiom shown above is safe in threaded