[Pyrex] getting data pointer to numpy object

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Mar 29 04:33:57 CEST 2006


Brian Blais wrote:

> ...but I would like to do something like...
> 
> #-------------------------------
> def test2(d):  # pass a python dict
> 
>     w=d['w']   # get the numpy object
> 
>     cdef double *w_p
> 
>     # get the pointers
>     w_p=<double *>w.data
> #-------------------------------

You can declare any variable as an ArrayType,
not just parameters. So

   def test2(d):
     cdef ArrayType w
     cdef double *w_p
     w = d['w']
     w_p = <double *>w.data

--
Greg



More information about the Pyrex mailing list