[SciPy-user] [Nipy-devel] how to wrap C++

Fernando Perez fperez.net at gmail.com
Thu Jan 18 00:44:07 CST 2007


On 1/17/07, Karl Young <Karl.Young at ucsf.edu> wrote:
>
> >Many of us happily use python for speed-critical code, and we feel
> >that a careful mix of python, numpy, pyrex and raw C provides a very
> >good environment with a minimal amount of confusion (since you
> >basically only need to know Python and C syntax, pyrex being a blend
> >of the two).
> >
> >
>
> Sorry for the tangential question but Fernando's post reminded me of a
> question I had which is what do scipy folks recommend
> these days re. wrapping C++ packages. I'm working on a project that
> would like to wrap a C++ NMR simulation package, either as a NiPy
> component or a standalone package to be used in conjunction with NiPy
> (need to determine the best way to do that - NiPy is primarily focused
> on neuroimaging and adding a spectroscopy component might be adding
> unnecessary clutter, even though the ultimate goal is analysis of
> spectroscopic imaging data). Before the original C++ package ceased it's
> evolution (a couple of years ago) one of the developers had gotten about
> halfway through using Boost to provide a python interface. I did a
> little bit of work with SWIG a few years ago but for a very small
> package. So we're not sure whether to try and complete the original
> effort (using newer versions of python and Boost) or to start over with
> a currently more appropriate choice. Any thoughts welcome, thanks,

What I recall from a while ago, as relayed by John Hunter (matplotlib)
and Prabhu Ramachandran (mayavi) was that while boost was great, the
compile times and the resulting binary library sizes were completely
out of control.  All that templating forces instantiation of an
enormous number of classes, which makes both time and size explode, to
the point of making both development and distribution seriously
problematic.  Both John and Prabhu decided to go with other
alternatives due to this, I think it was SWIG (whose C++ support has
greatly improved).

You might also want to have a look at this:

http://www.scipy.org/PyRoot

Root is a gigantic C++ framework coming from the data analysis world
of High-Energy physics (aka particle physics).  It was developed at
CERN and is very widely used.  This guy's talk was very interesting,
and they seem to have gone for their own (non-boost, non-SWIG)
solution, with arguments backing up their decision.

Cheers,

f


More information about the SciPy-user mailing list