[Python-Dev] reference leaks, __del__, and annotations

Neil Schemenauer nas at arctrix.com
Tue Apr 4 19:50:22 CEST 2006


Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Okay, so would it be possible for a generator that
> needs finalisation to set up a weakref callback, suitably
> rooted somewhere so that the callback is reachable,
> that references enough stuff to clean up after the
> generator, without referencing the generator itself?

I think so but it depends on what the finalizer needs to reference.
If it references into the cycle then we are back to the same
problem.  I think you could also do the same thing with a sub-object
that has the __del__ method.  Maybe the generator would only create
the sub-object if it needed to perform finalization.

  Neil



More information about the Python-Dev mailing list