[SciPy-dev] Sorting speed

Francesc Altet faltet at carabos.com
Sat Dec 31 05:52:05 CST 2005

```A Dissabte 31 Desembre 2005 05:06, Travis Oliphant va escriure:
> I've checked in sorting improvements to scipy_core SVN.

Wow! my numbers:

In [60]: t1 = timeit.Timer('a=array(None,shape=10000);a.sort()','from numarray
import array')

In [61]: t1.repeat(3,1000)
Out[61]: [0.63181209564208984, 0.60971593856811523, 0.61994194984436035]

In [62]: t2 = timeit.Timer('a=empty(shape=10000);a.sort()','from scipy.base
import empty')

In [63]: t2.repeat(3,1000)
Out[63]: [0.55068111419677734, 0.52086997032165527, 0.52183318138122559]

So, I can reproduce this also: scipy_core is more than 10% faster now :-)
But, interestingly enough:

In [65]: t3 = timeit.Timer('a=array(None,shape=10000);a.argsort()','from
numarray import array')

In [66]: t3.repeat(3,1000)
Out[66]: [1.2611861228942871, 1.2791898250579834, 1.2521131038665771]

In [67]: t4 = timeit.Timer('a=empty(shape=10000);a.argsort()','from scipy.base
import empty')

In [68]: t4.repeat(3,1000)
Out[68]: [0.77948904037475586, 0.76528811454772949, 0.81097602844238281]

so, argsort() is more than 60% faster in scipy_core than numarray.
Awesome! And argsort() is what PyTables actually use for create
indexes. Thank you very much not only for your responsiveness, but
also for the gorgeous quality of your work. I think I'll have to