Python 2.0
Graham Matthews
graham at sloth.math.uga.edu
Wed Jun 9 14:17:43 EDT 1999
Tim Peters (tim_one at email.msn.com) wrote:
: The caveats are explained well in the Java Language Spec, section 12.6. In
: short, you can't know which thread a finalizer will run in; you can't be
: sure that an object is unreachable at the time its finalizer is invoked; you
: can't know *when* a finalizer will be invoked; even if it is unreachable at
: the time its finalizer is invoked, you can't be sure that it won't become
: reachable again *after* the finalizer returns; and in the case of cyclic
: object structures nothing is specified about the order in which the objects'
: finalizers will be called (indeed, they may all run simultaneously).
There are two obvious answers to almost all the above problems in Python
a) don't call finalisers for circularly referenced collected objects.
Instead just collect their memory. This is not perfect but better than
current Python which doesn't run finalisers on circularly referenced
objects nor collect their memory.
b) better still use a two pass collector. If you don't know what that is
just think about what you need to do (or not do) in pass 1 to ensure
that all the objects needed for a __del__ method to execute in a known
environment are there. <wink>
graham
--
As you grow up and leave the playground
where you kissed your prince and found your frog
Remember the jester that showed you tears
the script for tears
More information about the Python-list
mailing list