[capi-sig] super() in Python/C
hniksic at xemacs.org
Wed Mar 11 10:22:11 CET 2009
After the initial controversy regarding Python's super(), I feel that
it's now fairly well-understood when it should be used and what
problems it solves. (Even if not, this list is probably not the right
medium for objections to super.) The one question I haven't seen
covered is whether and how to use it from C.
All of the Python/C code I've seen calls its base class(es) directly,
typically by only invoking the method of their superclass in the C
layout sense. This means that such code will call into the superclass
twice in a diamond inheritance scenario. For low-level classes that
are not expected to be multiply inherited this is not a problem. But
in some cases we need to convert higher-level classes from Python to C
for efficiency, either using Python/C, or a higher-level C++ wrapping.
The classes use super() with good reason, and I'd like to avoid
breaking them during conversion to C.
Is there a documented way to use super() from C, other than
instantiating PySuper_Type? Has anyone tried to do that?
More information about the capi-sig