[Numpy-discussion] ctypes and numpy

2010-12-07 Thread Sebastian Walter
Hello all, I'd like to call a Python function from a C++ code. The Python function has numpy.ndarrays as input. I figured that the easiest way would be to use ctypes. However, I can't get numpy and ctypes to work together. --- run.c #include Python.h #include

Re: [Numpy-discussion] ctypes and numpy

2009-11-07 Thread Zachary Pincus
Check out this thread: http://www.mail-archive.com/numpy-discuss...@lists.sourceforge.net/msg01154.html In shot, it can be done, but it can be tricky to make sure you don't leak memory. A better option if possible is to pre-allocate the array with numpy and pass that buffer into the C code --

Re: [Numpy-discussion] ctypes and numpy

2009-11-07 Thread Trevor Clarke
this looks like what I need...I'm not concerned with leaking memory as it's a borrowed pointer which will be cleaned up in C code later. Thanks for the pointer. On Sat, Nov 7, 2009 at 12:36 PM, Zachary Pincus zachary.pin...@yale.eduwrote: Check out this thread: