[Numpy-discussion] numpy array to C API

Robert Kern robert.kern@gmail....
Wed Mar 20 11:03:36 CDT 2013


On Wed, Mar 20, 2013 at 1:59 PM, Søren <sd@syntonetic.com> wrote:
> Greetings
>
> I'm extending our existing C/C++ software with Python/Numpy in order to do extra number crunching.
> It already works like a charm calling python with the C API <Python.h>.
>
> But what is the proper way of passing double arrays returned from Python/Numpy routines back to C?
>
> I came across PyArray but I can see in the compiler warnings, it is deprecated and I don't wanna start from scratch on legacy facilities.

What is this `PyArray` that you are referring to? There is nothing
named just `PyArray` to my knowledge. Do you mean direct access to the
`data` member of the PyArrayObject struct? Yes, that is deprecated.
Use the PyArray_DATA() macro to get a `void*` pointer to the start of
the data.

http://docs.scipy.org/doc/numpy/reference/c-api.array.html#PyArray_DATA

--
Robert Kern


More information about the NumPy-Discussion mailing list