[issue9417] Declaring a class creates circular references

Ray.Allen report at bugs.python.org
Fri Jul 30 11:09:17 CEST 2010


Ray.Allen <ysj.ray at gmail.com> added the comment:

> However here's a proposed solution:

* for the __mro__: instead of using a tuple, use a new object that inherits from it. This new object should use weak reference for the first item and should return the real object (if available) only in __getitem__().

* __objclass__ can should become a property based on weak references.



I'm afraid doing so could cause some public C API change. For example, the PyDescr_TYPE, if we implemented all the Descriptor object's d_type(that is the __objclass__ of all types of descriptors) based on weakref, we could have all the callers who call the descriptor functions to check weather the weak-referented class object has gone away.

----------

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


More information about the Python-bugs-list mailing list