[C++-sig] Status of Numpy support in boost python - II

Stefan Seefeld seefeld at sympatico.ca
Mon Jan 3 23:57:29 CET 2011


On 01/03/2011 04:44 PM, Ralf W. Grosse-Kunstleve wrote:
> ----- Original Message ----
>
>> From: Neal Becker<ndbecker2 at gmail.com>
>> To: cplusplus-sig at python.org
>> Sent: Mon, January 3, 2011 12:31:36 PM
>> Subject: [C++-sig] Status of Numpy support in boost python - II
>>
>> I was just re-reading these posts: Status of Numpy support in boost  python
>> http://web.archiveorange.com/archive/v/YJlerznoeRShLhlurQzC
>>
>> I  wonder if there are any updates?
>>
>> Is ndarray working with current (1.45.0)  boost?
> Boost.Python's existing numpy array support has been working all the time. It
> sounds like you are expecting new functionality. Could you be more specific?

One point that I'm particularly missing (and which I'm referring to in 
the thread cited above) is the ability to access raw pointers around. 
Here is a simple use-case illustrating my needs:

I have a library that uses a separation between data types ("blocks") 
and algorithms, akin to the C++ standard library. I would like to wrap 
that library in a way that allows me to access and share data with other 
Python packages using NumPy (notably SciPy), without the need to copy.
Right now that's impossible, since the only means to allocate NumPy 
arrays in boost.python is via the Python interpreter.

In my own wrapper, I use the much richer PyArray_New. The returned 
pointer is then usable via PyArray_GETPTR<X>, allowing me to implement a 
"Block" type that I can bind my library to directly.

Exposing such a rich API via boost.python obviously requires 
numpy/arrayobject.h to be available, at least during compilation of 
boost.python (or its numpy bindings), which may be considered inconvenient.

I would be very happy for any such addition into boost.python, and would 
be happy to help implement it.

Thanks,
         Stefan


-- 

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



More information about the Cplusplus-sig mailing list