[Numpy-discussion] Index Array Performance

Francesc Alted francesc at continuum.io
Tue Feb 14 04:03:30 EST 2012


On Feb 14, 2012, at 1:50 AM, Wes McKinney wrote:
[clip]
> But:
> 
> In [40]: timeit hist[i, j]
> 10000 loops, best of 3: 32 us per loop
> 
> So that's roughly 7-8x slower than a simple Cython method, so I
> sincerely hope it could be brought down to the sub 10 microsecond
> level with a little bit of work.

I vaguely remember this has shown up before.  My hunch is that indexing in NumPy is so powerful, that it has to check for a lot of different values for indices (integers, tuples, lists, arrays…), and that it is all these checks what is taking time.  Your Cython wrapper just assumed that the indices where integers, so this is probably the reason why it is that much faster.

This is not to say that indexing in NumPy could not be accelerated, but it won't be trivial, IMO.

-- Francesc Alted






More information about the NumPy-Discussion mailing list