[C++-sig] Numpy ndarray as argument or return value using boost python

Stefan Seefeld seefeld at sympatico.ca
Mon Oct 12 19:57:21 CEST 2009

On 10/12/2009 11:36 AM, Pim Schellart wrote:
> Hi Everyone,
> I also posted this to the boost users list.
> I tried to find a good example for this but after spending two days on
> google and one day getting pyublas to compile I decided to call for
> help.
> I want to give a numpy ndarray as an argument to a c++ method,
> calculate something and return the output as an ndarray to Python.
> I would prefer not to use another library (such as PyUblas) for this
> so I do not have to add another dependency to my program.
> Since the latest information on boost python is quite outdated (uses
> numeric) I would like to know the following.
> 1. Is boost python still maintained or should I switch to another tool.

Boost.Python is definitely maintained.

> 2. Is numpy supported, and if so,

That is a good question, to which I don't have an answer. In fact, I 
submitted an issue about the docs 
(https://svn.boost.org/trac/boost/ticket/3340), as a first step to 
getting an up-to-date picture.
Meanwhile, I have written my own wrapper for PyArray, as the existing 
one is by far not enough for my needs. (In particular, I need direct 
memory access.)

I would be happy to share this code and move it into boost.python, if in 
fact everyone agrees that what exists should be replaced.

David, Ralf, do you have an opinion on this ?

> 3. can someone give me a basic example of how to use it.



       ...ich hab' noch einen Koffer in Berlin...

More information about the Cplusplus-sig mailing list