[Numpy-discussion] speed problem with Numeric sort
Berthold Höllmann
hoel at germanlloyd.org
Tue Jun 19 10:37:38 EDT 2001
We have a speed problem with Numeric.sort on large arrays with only a
few different values. Here is my example
-- snip --
>cat numtst.py
import Numeric
print Numeric.__version__
class timer:
def __init__(self):
import time
self.start = time.time()
def stop(self):
import time
print "%.3f" % (time.time() - self.start)
from RandomArray import random
from Numeric import sort, Int
r=random((71400,))
t = timer() ; p=sort(r) ; t.stop()
r=(random((71400,))*70000).astype(Int)
t = timer() ; p=sort(r) ; t.stop()
r=(random((71400,))*70).astype(Int)
t = timer() ; p=sort(r) ; t.stop()
r=(random((71400,))*7).astype(Int)
t = timer() ; p=sort(r) ; t.stop()
16:27 hoel at seeve:hoel 2>python numtst.py
17.3.0
0.185
0.148
2.053
21.668
-- snip --
So the less different values are contained in the array the longer
takes the sorting. Is this also the case with newer versions of
Numeric (But this is Python 1.5.2)? Why is sorting of these arrays so
slow?
Thanks
Berthold
--
email: hoel at GermanLloyd.org
) tel. : +49 (40) 3 61 49 - 73 74
(
C[_] These opinions might be mine, but never those of my employer.
More information about the NumPy-Discussion
mailing list