weakref — Impermanent References to Objects — PyMOTW 3

The weakref module supports weak references to objects. A normal reference increments the reference count on the object and prevents it from being garbage collected. This is not always desirable, either when a circular reference might be present or when building a cache of objects that should be deleted when memory is needed. A weak reference is a handle to an object that does not keep it from being cleaned up automatically.

Read more…

This post is part of the Python Module of the Week series for Python 3. See PyMOTW.com for more articles from the series.