[Numpy-discussion] numpy array to C API

Valentin Haenel valentin@haenel...
Thu Mar 21 11:34:51 CDT 2013


Dear Søren,

* Søren <sd@syntonetic.com> [2013-03-21]:
> Your article fell in dry spot when a newbie in C/Python interfacing.
> Python-C-API fits perfectly with my current use-case.
> 
> I got currious about the Ctypes approach as well as "Gaël Varoquaux’s 
> blog post about avoiding data copies", but the link in the article 
> didn't seem to work. (Under "Further Reading and References")

There seems to be something wrong with Gaël's website. I have CC him,
maybe he can fix it.

best

V-

> 
> cheers
> Søren
> 
> On 21/03/2013 09:41, Valentin Haenel wrote:
> > Dear Søren,
> >
> > if you are new to interfacing python/numpy with C/C++, you may want to
> > check out:
> >
> > http://scipy-lectures.github.com/advanced/interfacing_with_c/interfacing_with_c.html
> >
> > Disclaimer: I am the author of this chapter, so this response is a bit
> > of a shameless plug :D
> >
> > Hope it helps.
> >
> > V-
> >
> > * Søren <sd@syntonetic.com> [2013-03-21]:
> >> Thanks Robert, for making that clear.
> >>
> >> I got a deprecated warning the second I added
> >> #include <numpy/arrayobject.h>
> >> and I got scared off too fast in my exploring phase.
> >>
> >> Cheers
> >> Søren
> >>
> >> On 20/03/2013 17:03, Robert Kern wrote:
> >>> 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
> >>> _______________________________________________
> >>> NumPy-Discussion mailing list
> >>> NumPy-Discussion@scipy.org
> >>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
> >> _______________________________________________
> >> NumPy-Discussion mailing list
> >> NumPy-Discussion@scipy.org
> >> http://mail.scipy.org/mailman/listinfo/numpy-discussion
> 
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion


More information about the NumPy-Discussion mailing list