[Numpy-discussion] Access to C/C++, typemaps, pyrex...

Andrew Straw strawman at astraw.com
Thu Mar 23 12:06:02 CST 2006

This example makes an __array_struct__ view of data you malloc 
elsewhere. In other words, it's only half of the full suite of what 
people may want to do. It covers elsewhere -> 
numpy/numarray/Numeric/__array_struct__ consumer.  It does not (yet) 
cover numpy/__array_struct__ producer -> elsewhere. This would be a 
great addition, but nontrivial to cover the full spectrum of memory 
allocation strategies that numpy currently provides. A first step might 
be to support only a limited set and raise a NotImplementedError if 
something more complicated is encountered.

I've actually been quite happy in my code doing something like 
allocating my own memory layouts, passing a view of them to numpy using 
this interface, doing any manipulation there, and then continuing on in 
my own code. This could, for example, be used to make a numpy view of a 
wx-allocated buffer... FWIW, I'm using Intel's IPP to both allocate 
buffers and further manipulate them, with my Python interface 
significantly eased by a numpy view of the data.

But, like I say, I understand this is only half the solution... The wiki 
is open for submissions!

Francesc Altet wrote:

>I've just noticed it. That's great, but I don't understand the code
>quite well. In particular, if, as the introduction says, this offers
>"a view of the data without actually copying the data itself", then
>why the next line is needed?:
>    self.data=<fiptr>malloc( bufsize )
>Oh, well, I think I've to study more the example.

More information about the Numpy-discussion mailing list