what is the best way to pass c, c++ array to numpy in cython?
hello, what is the best way to pass c, c++ array to numpy in cython? or what is the best way to pass fortran multi-dimensional array to numpy in cython? Wonjun, Choi
On Tue, Jan 03, 2012 at 07:56:52PM -0800, Wonjun, Choi wrote:
what is the best way to pass c, c++ array to numpy in cython?
I don't know if it is the best way, but I wrote a self-contained example a little while ago, to explain to people one way of doing it: http://gael-varoquaux.info/blog/?p=157 For multidimensional arrays, all you have to do is to pass in the full shape and number of dimensions in the call to PyArray_SimpleNewFromData. Hope this helps, Gael
it seems like you recommend below way. Cython example of exposing C-computed arrays in Python without data copies https://gist.github.com/1249305 but it uses malloc. isn't it?
On Thu, Jan 05, 2012 at 11:26:05AM +0900, 최원준 wrote:
it seems like you recommend below way. Cython example of exposing C-computed arrays in Python without data copies [1]https://gist.github.com/1249305
but it uses malloc. isn't it?
In this example, the data can be allocated the way you want in C. Malloc is just an implementation detail, you can write the code you want instead. Gael
can I pass the array without malloc?
participants (3)
-
Gael Varoquaux -
Wonjun, Choi -
최원준