[Numpy-discussion] Best way to insert C code in numpy code
Tue Sep 22 12:13:57 CDT 2009
René Dudfield wrote:
> On Mon, Sep 21, 2009 at 8:12 PM, David Warde-Farley <email@example.com> wrote:
>> On 21-Sep-09, at 2:55 PM, Xavier Gnata wrote:
>>> Should I read that to learn you cython and numpy interact?
>>> Or is there another best documentation (with examples...)?
>> You should have a look at the Bresenham algorithm thread you posted. I
>> went to the trouble of converting some Python code for Bresenham's
>> algorithm to Cython, and a pointer to the Cython+NumPy tutorial:
> I don't know about the best way... but here are two approaches I like...
> Another way is to make your C function then load it with ctypes(or
> wrap it with something else) and pass it pointers with
> array.ctype.data. You can find the shape of the array in python, and
> pass it to your C function. The benefit is it's just C code, and you
> can avoid the GIL too if you want. Then if you keep your C code
> separate from python stuff other people can use your C code in other
> languages more easily.
> cinpy is another one(similar to weave) which can be good for fast
> prototyping... http://www.cs.tut.fi/~ask/cinpy/ or for changing the
> code to fit your data.
Well I would have to find/read docs to be able to try that solution.
cython looks easy :)
More information about the NumPy-Discussion