On Jan 20, 2009, at 12:35 PM, Ilmar Wilbers wrote:

> Hi,
>
> Would it be possible to send a pointer from one function to  
> another? For
> instance if I have the following function:
> def array2vector(a):
>     cdef float *p = <DTYPE_t*>a.data
>     cdef float *v = vector(1, a.shape[0])
>     for i in range(a.shape[0]):
>         v[i+1] = a[i]
>     return <object>p
>
> is it then possible to grab this pointer in another function:
> cdef float *p = <float*>array2vector(a)
>
> at all? If so, how, because trying the above gives me the error
> Casting temporary Python object to non-numeric non-Python type

Yes, you either have to make it a cdef function (where the arguments  
and return type can be declared to be float*) or wrap it in another  
object (such as a numpy array).

- Robert

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to