[Cython] c-array of numpy ndarrays?

Brian Blais bblais at gmail.com
Fri May 8 15:51:02 CEST 2009


Hello,

In my question for optimization of my routines, I am trying to pre- 
fill a static c-array from a list of numpy ndarrays.  Previously, I  
did something like:

cdef double *w[30]
cdef int r[30],c[30]

and then I'd run through my list, and get the shape info and the data  
pointer, and fill in these arrays.  This works, but then I have to do  
all my 2D -> 1D indexing, like:

w[k][i+c[k]*j]

which is ugly, and prone to typos.  I'd like to do:

cdef np.ndarray w[30]

so I can do the nicer:

w[k][i,j]

I tried making an array of buffer objects, but I can only make local  
versions of that.  c-arrays of python objects are forbidden.  Is  
there a c-version of the ndarray?


			thanks,

				Brian Blais
--
Brian Blais
bblais at gmail.com
http://web.bryant.edu/~bblais

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codespeak.net/pipermail/cython-dev/attachments/20090508/2e27801a/attachment.htm 


More information about the Cython-dev mailing list