Re: [Numpy-discussion] Best way to insert C code in numpy code

2009-09-22 Thread Xavier Gnata
René Dudfield wrote: > On Mon, Sep 21, 2009 at 8:12 PM, David Warde-Farley > 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 shou

Re: [Numpy-discussion] Best way to insert C code in numpy code

2009-09-22 Thread René Dudfield
On Tue, Sep 22, 2009 at 3:45 PM, Sturla Molden wrote: > Xavier Gnata skrev: >> I have a large 2D numpy array as input and a 1D array as output. >> In between, I would like to use C code. >> C is requirement because it has to be fast and because the algorithm >> cannot be written in a numpy oriente

Re: [Numpy-discussion] Best way to insert C code in numpy code

2009-09-22 Thread Sturla Molden
Xavier Gnata skrev: > I have a large 2D numpy array as input and a 1D array as output. > In between, I would like to use C code. > C is requirement because it has to be fast and because the algorithm > cannot be written in a numpy oriented way :( (no way...really). > There are certain algorithm

Re: [Numpy-discussion] Best way to insert C code in numpy code

2009-09-22 Thread Sturla Molden
René Dudfield skrev: > Another way is to make your C function then load it with ctypes Also one should beware that ctypes is a stable part of the Python standard library. Cython is still unstable and in rapid development. Pyrex is more stabile than Cython, but interfacing with ndarrays is harder

Re: [Numpy-discussion] Best way to insert C code in numpy code

2009-09-22 Thread Sturla Molden
René Dudfield skrev: > 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. numpy.ctypeslib.ndpointer is preferred when using ndarrays with ctypes. > You can find the shape of the array in python, and > p

Re: [Numpy-discussion] Best way to insert C code in numpy code

2009-09-22 Thread René Dudfield
On Mon, Sep 21, 2009 at 8:12 PM, David Warde-Farley 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

Re: [Numpy-discussion] Best way to insert C code in numpy code

2009-09-22 Thread Chris Colbert
I give my vote to cython as well. I have a program which uses cython for a portion simply because it was easier using a simple C for-loop to do what i wanted rather than beating numpy into submission. It was an order of magnitude faster as well. Cheers, Chris On Mon, Sep 21, 2009 at 9:12 PM, Dav

Re: [Numpy-discussion] Best way to insert C code in numpy code

2009-09-21 Thread David Warde-Farley
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 B

Re: [Numpy-discussion] Best way to insert C code in numpy code

2009-09-21 Thread Christopher Barker
Xavier Gnata wrote: > David Cournapeau wrote: >> That's only a data point, but I almost always use cython in those cases, I'm a second data point, but I think there are many more. Judging from the SciPy conference, Cython is the preferred method for new projects. > Should I read that to learn y

Re: [Numpy-discussion] Best way to insert C code in numpy code

2009-09-21 Thread Xavier Gnata
David Cournapeau wrote: > Xavier Gnata wrote: > >> Hi, >> >> I have a large 2D numpy array as input and a 1D array as output. >> In between, I would like to use C code. >> C is requirement because it has to be fast and because the algorithm >> cannot be written in a numpy oriented way :( (no wa

Re: [Numpy-discussion] Best way to insert C code in numpy code

2009-09-21 Thread David Cournapeau
Xavier Gnata wrote: > Hi, > > I have a large 2D numpy array as input and a 1D array as output. > In between, I would like to use C code. > C is requirement because it has to be fast and because the algorithm > cannot be written in a numpy oriented way :( (no way...really). > > Which tool should I

[Numpy-discussion] Best way to insert C code in numpy code

2009-09-20 Thread Xavier Gnata
Hi, I have a large 2D numpy array as input and a 1D array as output. In between, I would like to use C code. C is requirement because it has to be fast and because the algorithm cannot be written in a numpy oriented way :( (no way...really). Which tool should I use to achieve that? waeve.inline