[SciPy-user] weave and access to Numeric arrays

Fernando Perez fperez at pizero.colorado.edu
Mon Jul 22 21:13:36 CDT 2002


Hi Eric,

here's a followup. I suspect your 'from scipy import *' was triggering a call 
to the normal Numeric sum() function instead of the C one you gave me. Because 
when I moved that code to another file it didn't work :)

Don't worry about details now, by compiling the code with verbose=2 I found 
where the .cpp file was and now I'm reading that. So the details are coming to 
light :)

I'm wondering why you chose the following:

        int* _Nx = x->dimensions;
        int* _Sx = x->strides;
        int _Dx = x->nd;
        float* x_data = (float*) x->data;

why not x_dimensions, x_strides, ..? esp. since you have x_data? It seems like  
a slightly more natural naming convention. But I guess now at least I realize 
that the lines

py_x= get_variable("x",raw_locals,raw_globals);
PyArrayObject* x = convert_to_numpy(py_x,"x");

mean that x is available in all its glory in the C code, so as long as I read 
the Numpy C API docs I should be able to survive.

Thanks a lot for your help. Once I understand all this I'll update my 
weave_examples page and post the link here.

Cheers,

f.




More information about the SciPy-user mailing list