does python have useless destructors?

Isaac To kkto at csis.hku.hk
Thu Jun 17 11:13:45 EDT 2004


>>>>> "David" == David Turner <dkturner at telkomsa.net> writes:

    David> So are we to take it that efficiency considerations are a serious
    David> impediment to a potentially valuable safety feature?

I tried to think in exactly this way a couple of days ago.  But soon I
concluded that we already got what we can possibly get: CPython is actually
garbage collected with reference counting, dealing with loops as a special
case.  There the Python runtime implements everything, and as such it can
dictate a slower but perhaps more predictable method as garbage collection.
Jython runtime do not try to manage objects, and leave it to the Java
runtime.  There is no way to implement reference counting there, unless one
want to give up the possibility of using Java objects in Jython and vice
versa.  And still we cannot rule out a possibility that we will have our
compiled counterpart (Psyco?) finding that reference counting is a
perfermance bottleneck, and in that case it is very legitimate for it to
change reference counting method to something else like copy collection.  So
for program to be run in CPython only, one may find it convenient to assume
that reference counting is used.  But for any portable code, one must be
more careful---exactly our current situation.  We need no more discussion
about how to collect garbages.  On the other hand, PEP 310 discusses
something completely unrelated, which still should attract some eyeballs.

Regards,
Isaac.



More information about the Python-list mailing list