Inheritance for native types is not supported
Default load_attr implementation (as used for all native types) doesn't take type inheritance (->bases_tuple) into account. I'm working on OrderedDict implementation, and it inherits most of its methods from dict, but adds few (well, 1) new method. Of course, this new method can be ignored, and old trick of putting the same .locals_dict to both types can be used. But I wanted to look into making truly inheritable methods, which requires setting custom .load_attr type method. And we already have implementation of this method which takes inheritance into account - for user classes/instances. But trying to use it, it assumes that object whose attr is being looked up is instance, so making it work with native objects means adding even more conditions to existing bunch of those (and which are already pretty mind-boggling). Another alternative is to make clean, "optimized" inheritance-friendly .load_attr for native types, but that means code duplication (and refactoring of existing code paths, factoring out functions, which means more stack usage, etc.)
Any thoughts?
To support multiple inheritance, should filter out "object" from base class spec and handle it as implicit fallback
We're not going to get proper Python MRO any time soon (#525), but to at least not break multiple inheritance (MI) in obvious way, we should at least do following:
- Filter out "object" from any explicit base class specification. (turn
class Foo(object)intoclass Foo). - Look up attributes in "object" as a fallback.
This will emulate the fact that in Python3, "object" is always the last type in MRO.
Failing to do the above may mean, that with our naive depth-first MRO, "object" ultimate base of first superclass in MI case may seize method call destined to another superclass, if "object" has such method. With #520 & #606, object now implements __new__ and __init__, so any other multi-superclass will be denied construction and initialization.