How to make a C extension module backwards compatible?

Andrew McNamara andrewm at
Wed Sep 18 01:08:48 EDT 2002

>> Is there any community wisdom on how to make a C extension module that
>> implements a new-style class (type?) backwards compatible (albeit,
>> at the cost of some functionality)?
>> Put another way, how *should* I make a class implemented in C behave
>> like a new-style class when installed with python 2.2 and above, and
>> like an old style class when installed with older pythons?
>What properties of a new-style class are you interested in? If you
>implement a plain type, it will work on all Python versions, no need
>to change anything for Python 2.2.

That's a good question - this is more of a learning exercise than a
project with a real need. I guess the most useful attribute would be

We have an existing module that implements a fast csv parser[1] - if
it's easy to make it's "parser" class able to be sub-classed, it would
be worth doing it (I guess the socket module is a decent example).


Andrew McNamara, Senior Developer, Object Craft

More information about the Python-list mailing list