Open thouis opened 12 years ago
Comment in Trac by atmention:alberts, 2007-05-12
Comment in Trac by atmention:cournape, 2008-11-20
Comment in Trac by atmention:cournape, 2009-03-02
Comment in Trac by atmention:mwiebe, 2011-03-23
Here's a small benchmark illustrating the problem:
In [1]: import numpy as np
In [2]: np.__version__
Out[2]: '2.0.0.dev-7219ac2'
In [3]: a = np.random.random(100000)
In [4]: amask = a > 0.9
In [5]: b = a.reshape(100,1000)
In [6]: bmask = amask.reshape(100,1000)
In [7]: timeit a[amask]
1000 loops, best of 3: 787 us per loop
In [8]: timeit b[bmask]
1000 loops, best of 3: 1.22 ms per loop
Original ticket http://projects.scipy.org/numpy/ticket/274 Reported 2006-09-06 by atmention:teoliphant, assigned to unknown.
Currently N-D Boolean indexing works by creating intermediate integer index arrays for N>1. This should be avoided when possible so that Boolean indexing is faster for N>1.