inheritance, multiple inheritance and the weaklist and instance dictionaries
Rouslan Korneychuk
rouslank at msn.com
Wed Feb 9 13:54:41 EST 2011
I'm working on a program that automatically generates C++ code for a
Python extension and I noticed a few limitations when using the weaklist
and instance dictionaries (tp_weaklistoffset and tp_dictoffset). This is
pertaining to the C API.
I noticed that when using multiple inheritance, I need a common base
class or I get an "instance lay-out conflict" error (my program already
deals with the issue of having a varying layout), but the error also
happens when the derived classes have these extra dictionaries and the
common base doesn't. This doesn't seem like it should be a problem if
the offsets for these variables are explicitly specified in the derived
types. I want this program to be as flexible as possible, so could
someone tell me what exactly are the rules when it comes to these
dictionaries and inheritance. Also, I don't like the idea of having up
to four different classes (one for every combination of those two
variables) that do nothing except tell CPython that I know what I'm doing.
Also is it possible to have a class that doesn't have these dictionaries
derive from a class that does?
I don't mind hackish solutions as long as they work reliably with
multiple Python versions.
More information about the Python-list
mailing list