Guido van Rossum added the comment: Kristjan, it seems you're in over your head. :-)
The mro() function is documented here: http://docs.python.org/3/library/stdtypes.html?highlight=mro#class.mro It exists to be called instead of using __mro__ directly; a metaclass can then override what it returns. (Though I don't know if anyone has ever done this.) The code you quote is in PyType_Ready() and skips bases[0] because bases[0] has already been used as the basic "template" for the C-level layout of the instances. This particular loop adds additional slots to the layout and (most importantly) verifies that no bases are in conflict with the layout enforced by bases[0]. (This is required because we don't actually implement "virtual slots" at this level -- the C-level layout can only extend the first base class's layout.) BTW, Armin is also right about the reason for using weak references in the __subclasses__ list. As for replacing references with weak references, I would be much more concerned if you were proposing this for e.g. bound methods or instances, but that doesn't mean I'm completely unconcerned... In addition to worrying about breaking (obscure) code that might depend on those references, I worry that it is trying to optimize for an unusual case (dynamically created classes in a world where you don't want to call gc.collect()) but slowing down the common case (access of the class from the descriptor every time a descriptor is used). Specifically about your patch, I'm pretty sure there are some calls in there that don't expect a NULL pointer, as d_type is never NULL; but adding the weak reference makes it possible that your macro will return a NULL pointer. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17950> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com