[Numpy-discussion] Cython: Passing numpy array into C via buffer?
Richard Shaw
jrs65 at cam.ac.uk
Fri Sep 26 07:01:29 EDT 2008
Dag Sverre Seljebotn wrote:
> I'm sorry, my previous answer was a really, really bad one. Here's a
> better one:
>
> data = <double*>numarr.data
>
> :-) With the addition of the _t on float64 this should just work.
That sounds great. I thought there must be something like that, it's
glad to see that Cython doesn't disappoint. I'll get straight to trying
it out.
> Please insert an extra check to make sure that your data is contiguous
> though! Otherwise you need to make a copy to pass the data to an
> external lib (one way is by using numpy.array with a contiguouos
> argument to construct a copy, and then copy the data back again afterwards).
That make sense. I'll be sure to do check that one.
Thanks for your very swift response, it's really helpful. I'll be sure
to post to the Cython-dev list in future if that's more appropriate.
Cheers,
Richard
More information about the NumPy-Discussion
mailing list