New in version 2.1. The weakref module allows the Python
programmer to create weak references to objects. In the
following, the term referent means the object which is referred
to by a weak reference. A weak reference to an object is not
enough to keep the object alive: when the only remaining
references to a referent are weak references, garbage collection
is free to destroy the referent and reuse its memory for
something else. A primary use for weak references is to
implement caches or mappings holding large objects, where it’s
desired that a large object not be kept alive solely because it
appears in a cache or mapping. For example, if you have a number
of large binary image objects, you may wish to associate a name
with each. If you used a Python dictionary to map names to
images, or images to names, the image objects would remain alive
just because they appeared as values or keys in the
dictionaries. The WeakKeyDictionary and WeakValueDictionary
classes supplied by the weakref module are an alternative,