What are the differences between _weak_ references and "normal" references?

Ben Hutchings do-not-spam-ben.hutchings at businesswebsoftware.com
Fri Apr 4 19:24:17 CEST 2003

In article <169a7283.0304040901.4bc3531b at posting.google.com>,
sdieselil wrote:
> Hi
> I noticed a module weakref in Python standard library. What is weak
> reference and in what way it differs from "normal" reference? By the
> way, how can I implement usual reference in Python (I mean C++
> reference)?

All Python variables are references, but unlike C++ references they can
be rebound.  In Python, copying objects is unusual.

In a garbage-collected environment like Python, a weak reference is one
that does not prevent its target from being destroyed, but is instead
nullified (in Python, set to None) when the target is destroyed.

More information about the Python-list mailing list