[SciPy-dev] Sorting speed
Travis Oliphant
oliphant.travis at ieee.org
Fri Dec 30 20:28:20 EST 2005
Try this little experiment, though to see numarray performance on
sorting N-d arrays:
>>> t1 = timeit.Timer('a = empty(shape=(100,100));a.sort(0)','from
scipy import empty')
>>> t2 = timeit.Timer('a = array(None,shape=(100,100));a.sort(0)','from
numarray import array')
>>> t1.repeat(3,100)
t2.rep[0.58475184440612793, 0.63138318061828613, 0.61224198341369629]
>>> t2.repeat(3,100)
[3.3455381393432617, 3.2438080310821533, 3.2775850296020508]
>>> import scipy.base._sort
>>> t1.repeat(3,100)
[0.26787090301513672, 0.21700596809387207, 0.21253395080566406]
The last one changes to a type-specific sort for int32 arrays, leading
to about a 3x speed up. This is sorting over the first axis.
So, it looks like even without changing the sorting, for Nd arrays
sorting is much faster in scipy_core. If we improve to type-specific
sorting, then the sorting is much, much faster in scipy_core.
-Travis
More information about the SciPy-Dev
mailing list