[Numpy-discussion] Access to C/C++, typemaps, pyrex...
Travis Oliphant
oliphant at ee.byu.edu
Thu Mar 23 10:36:01 EST 2006
Christopher Barker wrote:
> Fernando Perez wrote:
>
>> Done, both for pyrex and swig. I added very simple notes, feel free
>> to add further detail as necessary:
>>
>> http://scipy.org/Cookbook/Pyrex_and_NumPy
>> http://scipy.org/Cookbook/SWIG_and_NumPy
>
>
> Thanks, this is great.
>
> Has anyone done this (for either SWIG or Pyrex) for the generic array
> interface, rather than explicitly for the numpy types? I'd love to see
> examples of how to write extensions that can take ANY nd-array. (I now
> that's only NumPy, Numeric and numarray now, but I'm hopeful it will
> become a standard)
Well, there is the __array_struct__ method that should return a C-Object
pointer with all the information in it about the array.
To see how to use this look at the Numeric or numpy code (do a grep on
__array_struct__ and you will find the relevant sections of code).
I noticed that the Pyrex cookbook had an example with using the generic
interface.
-Travis
More information about the NumPy-Discussion
mailing list