[pypy-dev] missing things for making PyPy "production" ready (for some value of production)

Amaury Forgeot d'Arc amauryfa at gmail.com
Mon Nov 19 07:36:46 CET 2007


David Cournapeau wrote:
> > No.  You can use py++ if you like to generate boost::python.  This (py++) is
> > fairly new, and I believe relatively few boost::python users follow this
> > route.  Most of us write boost::python wrappers by hand (it's usually
> > pretty easy).
> I was talking in the context of automating wrapping. Of course, you can
> wrap by hand, and it is as easy as in C for a few functions (I myself
> much prefer ctypes, though, but I am obviously biased against C++ :) ).
> But for 500 classes / 3000 functions, I doubt this is practical (the
> only big C++ wrapper I am somewhat familiar with in python is pyqt,
> which uses its own thing for the wrapping...).

wxPython has the same number of functions, and uses Swig to do the wrapping.

> Once you need something at least partially automatic, you need parsing
> the code you are wrapping. For pypy, this is what is needed, no ?

This is not necessary, and sometimes not suitable.
With Swig for example, the syntax for classes and function
declarations is indeed based on C++, but you often need a lot of
tweaks to make it generate code that will work properly. These are
called "typemap", "extend", "director" and other "features", and these
additional directives are not C++.

Swig uses an internal representation of the parsed file, which can be
dumped to XML for example. It is possible to imagine another way to
create the same representation and have the same wrapper generated. Of
course I have something like rffi in mind...
I don't think that Swig itself can be used by pypy, I just wanted to
show that automatic wrapping of C++ is possible and can be used by
pypy, without the help of ctypes.

Cheers,

-- 
Amaury Forgeot d'Arc



More information about the Pypy-dev mailing list