[Numpy-discussion] Re: STL wrapper for PyArrayObject

Chris Barker cbarker at jps.net
Tue Jan 9 12:55:11 CST 2001


Phlip TheProgrammer wrote:

> And using CXX, we wrap these objects in high-level C++ methods. Not the low-level fragile C. The effect compares favorably to ATL for VC++ and ActiveX.

> If we pass a multiarray into a function expecting a PyArrayObject, how then do we add new elements to it? I tried things like 'push_back()' and 'setItem()', but they either did not exist or did not extend the array.
> 
> Am I going to have to generate a new array and copy the old one into the new?

I waited a little while before answering this, because there are
certainly people more qualified to do so that me. I am only on the NumPy
list, so it may have been answered on a different list.

The short answer is yes, you will have to generate a new a array and
copy the old one into the new. MultiArray objects were created to
provide efficient storage of lots of numbers (among other things).
Because of this requirement, the numbers are stored as a large single
array, and so they cannot be re-sized without re-creating that array.
You may be able to change just the data array itself (and a few
properties), rather than creating a new structure entirely, but it
probably wouldn't be worth it.

By the way, I'd like to hear how this all works out. Being able to use
NumPy Arrays in extensions more easily would be great!

-Chris





-- 
Christopher Barker,
Ph.D.                                                           
cbarker at jps.net                      ---           ---           ---
http://www.jps.net/cbarker          -----@@       -----@@       -----@@
                                   ------@@@     ------@@@     ------@@@
Water Resources Engineering       ------   @    ------   @   ------   @
Coastal and Fluvial Hydrodynamics -------      ---------     --------    
------------------------------------------------------------------------
------------------------------------------------------------------------




More information about the Numpy-discussion mailing list