C++ version of the C Python API?
Carl Banks
pavlovevidence at gmail.com
Sun Oct 21 19:15:51 EDT 2007
On Sun, 21 Oct 2007 16:17:19 -0500, Robert Dailey wrote:
> On 10/21/07, "Martin v. Löwis" <martin at v.loewis.de> wrote:
>> No, I literally meant that the Python C API is object-oriented. You
>> don't need an object-oriented language to write object-oriented code.
>
> I disagree with this statement. C is not an object oriented language,
> and I've seen attempts to make it somewhat object oriented, however it
> failed miserably in readability and manageability overhead. However,
> this isn't the place to discuss such a thing so I've got nothing more to
> say than that.
What he means is that the C API provides a complete, if boilerplate-
heavy, interface to object oriented aspects of Python. I.e., you can
write Python types completely in C, including all the OOPy stuff like
inheritance and so on. You don't need a language with built-in support
of OOP to do that.
Now, a C++ API for CPython would necessarily be built on top of the C
API, which carries some limitations relative to the OOP abilities of C++
itself. I suspect all you'll get from a C++ binding is a slightly more
comfortable (to people who like C++) calling interface. It could help
bring some unity to your extension code, and maybe get rid of a few
typecasts and simplify function names. But you shouldn't expect anything
like the ability to freely inherit between C++ and Python classes.
Carl Banks
More information about the Python-list
mailing list