[Numpy-discussion] my cython is slow

John Hunter jdh2358@gmail....
Thu Jan 8 11:32:32 CST 2009

On Wed, Jan 7, 2009 at 5:37 PM, Eric Firing <efiring@hawaii.edu> wrote:

> A couple small changes speed it up quite a bit:
> efiring@manini:~/temp/nnbf$   python test_nnbf.py
> loading data... this could take a while
> testing nnbf...
>    10 trials: mean=0.0150, min=0.0100
> testing numpy...
>    10 trials: mean=0.0660, min=0.0600
> It is all a matter of keeping Python objects and function calls out of inner
> loops.  I suspect there is quite a bit more that could be done in that
> regard, but I haven't looked.

Much  faster, but no longer correct, as you'll see if you uncomment
out the nose test test_neighbors that compare actual vs desired.

Is the pointer arithmetic correct:

  dataptr + i

I would have thought perhaps:

  dataptr + i*n

but this is segfaulting.  Do we need to use a stride?


More information about the Numpy-discussion mailing list