need an example of Python numarray to C++ and back again, Boost / SWIG?

Fernando Perez at
Thu Nov 10 05:59:56 CET 2005

PL wrote:

> I want to pass a 2D array from Python to C++, manipulate it in C++ (for
> example, add 1 to each element) and pass it back to Python.
> With these building blocks I will be able to figure out all the rest of
> what I need to do for my project.  I am very familiar with Python, but
> less so with C++ and Boost or SWIG.
> Does anyone have an example with all steps that I can follow?  More
> specifically I am looking for the C++ code, ".i" file for SWIG and/or
> the analagous setup files that Boost would need to do this.

You may want to look into weave.inline or weave.blitz, from scipy.  Typemaps for
conversion to blitz++ were recently posted on the scipy list:

In particular look at Stefan's post.

For info on weave, here you can find some old slides and example code:



More information about the Python-list mailing list