[issue9141] Allow objects to decide if they can be collected by GC

Kristján Valur Jónsson report at bugs.python.org
Fri Apr 6 22:24:42 CEST 2012


Kristján Valur Jónsson <kristjan at ccpgames.com> added the comment:

Right Daniel, but currently an exception is made for Generator objects.  The generator can tell that the finalizer won't do anything and then allow collection regardless.  It knows the finalizer and that in its state it will at most do some Py_DECREF operations.

This patch aims to generalize this exception mechanism, and also its opposite, so that we don´t need to rely on the presence of the finalizer slot to decide.  We can then remove a silly function from the public (but undocumented) API.

Of course, you can only allow collectino of an object with a finalizer if you know for sure that it will not do anything but Py_DECREF.  This is possible for generators because they are not an inheritable class.  But we could never do this in general for a python class.  Even running .py code from the GC collector cycle would crash everything instantly.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9141>
_______________________________________


More information about the Python-bugs-list mailing list