[Python-Dev] Making weakref callbacks safe in cyclic gc

Greg Ewing greg at cosc.canterbury.ac.nz
Mon Nov 17 20:21:45 EST 2003


Tim Peters <tim at zope.com>:

> So getting at "self" is a puzzle for a weakref callback pointing at
> self.

How often does a finalizer really *need* access to the entire object
that triggered the finalization, and not just some part of its state?

I remember reading once about the finalization scheme used in a
particular Smalltalk implementation (I think it was ParcPlace) in
which an object requiring finalization registers another object to be
notified after it has died.

This seems to be more or less equivalent to what we have with weakref
callbacks. It might be worth studying how they deal with reference
cycles in their system, since the same solution may well apply to us.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+



More information about the Python-Dev mailing list