[Pyrex] Re: Re: Pyrex and C++

Andreas Kostyrka andreas at mtg.co.at
Wed Nov 19 12:47:42 CET 2003


On Tue, Nov 18, 2003 at 11:47:38PM -0500, David J. C. Beach wrote:
> On Wed, 2003-11-19 at 08:29, Greg Ewing wrote:
> > Mike Rovner <mike at nospam.com>:
> > 
> > > I love pyrex and use it all the way to link with C
> > > prefer to use boost to link to C++.
> > > 
> > > So my question still stand - why do we need C++ compilation mode?
> > 
> > You might not want to, but other people have expressed a desire
> > to use Pyrex for this. I haven't decided whether I'm going to
> > do this or not yet, but we're talking about what it would take
> > if I do.
> 
> Boost.Python is a great project, and I know it does an excellent job of
> allowing the user to create extension types and functions in C++.  SIP
> and SWIG allow this as well (although they require special interface
> files).  All of these tools are great if you want to write the extension
> type in C or C++.
> 
> However... Pyrex is the only project I'm aware of which allows the user
> to create an extension type in a language that is much closer to
> Python.  For a user with a Python background, this is a wonderful thing.
Well, more important, while Boost, SWIG and SIP all allow the creation of 1:1
wrappers, Pyrex allows for creating a new interface design that builds upon
the C library. Basically I can create a Python type/class that uses whatever
is needed in the underlying library to accomplish it's goal.

One can naturally claim that this is also possible with SWIG&Co by using a
Python module to mask. But this can be sometimes inacceptably slow. In Pyrex
I get all the benefits of a custom C language module, like naturalness of the 
interface, performance, etc., in a Python-ish language, that needs almost
zero learning, at least for people knowing Python, C well enough (probably a
bit knownledge about the Python-C API helps too, but it's not necessary).

That makes C++ support in Pyrex a very important thing.

BTW, C++ exceptions do not have to propagate trough C modules. It's
implementation specific. (I'm not sure, but I think GTK or Python had to
deal with that problem.)

Andreas




More information about the Pyrex mailing list