inheritance

Paul McGuire ptmcg at austin.rr.com
Mon Jul 11 05:18:47 CEST 2005


I'm not intimate with Python's C/C++ implementation, but is it possible
that your modified code may not be implementation portable?  For
instance, if some calculation of the size of the object is required,
inherited classes may layout data differently than contained classes
would, especially if classes do not contain a "nice" (i.e.,
word-boundary) number of bytes.

Or is it possible that there are other Python routines that access the
mBase field, perhaps for some form of introspection?  What you might do
is convert one of the existing typedefs to use your form, then build an
run Python regression tests, preferably on Win, Mac, and *nix.  Or at
least run your own alternative PyStructDerivedClass through a series of
tests that specifically target and exercise the class hierarchy.

(I'm sorry if I'm proposing an onerous build/test burden, but if you
want your C++ code to generally adopted, while straying from accepted
practices, then you should probably prepare to put in some extra effort
to validate your alternative approach.)

I agree, your approach looks much cleaner.  Unfortunately, in the face
of having to support many platforms and compilers, Python
implementation and extension may constrain developers to a clearly
portable subset of language features.

-- Paul




More information about the Python-list mailing list