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

Christopher Barker Chris.Barker at noaa.gov
Thu Mar 23 11:41:04 CST 2006


Francesc Altet wrote:
> A Dijous 23 Març 2006 18:58, Christopher Barker va escriure:
>> Has anyone done this (for either SWIG or Pyrex) for the generic array
>> interface, rather than explicitly for the numpy types?

> I don't think this is feasible yet,

um, why not?

> although I don't think this is a
> big limitation. You can always compile your program against NumPy or
> numarray or Numeric

The goal here is to be able to write code that can be compiled without 
the presence of numpy, or Numeric, or numarray. Indeed, no additional 
dependencies, but that can still efficiently use array objects passed in.

My classic example is wxPython. Robin doesn't want any dependencies on 
other packages, so at the moment, when you pass a numpy array in, it 
uses python's generic sequence access to get the values, then ends up 
converting them to a plain old C array. This is a lot of unnecessary 
processing, as you can imagine.

I think it can be done, and one of these days I'll figure out how, but 
I'd love to see an example from someone who understands these things 
more than myself.

Travis Oliphant wrote:

> 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).

That's exactly what I mean. Now I just need to figure out how to use it!

> I noticed that the Pyrex cookbook had an example with using the generic 
> interface. 

Wonderful, I'll go look there.

Do you mean the Pyrex section in the SciPy cookbook? I can't find a 
Pyrex cookbook.

Thanks, -Chris


-- 
Christopher Barker, Ph.D.
Oceanographer
                                     		
NOAA/OR&R/HAZMAT         (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov





More information about the Numpy-discussion mailing list