[SciPy-dev] Sorting speed

Alan G Isaac aisaac at american.edu
Fri Dec 30 17:58:10 CST 2005


> Alan G Isaac wrote: 
>> On my computer, it seems almost all that difference is due 
>> to the time difference in initializing the arrays.  (I.e., 
>> much of it disappears if I put the array creation in the 
>> setup statement.) 

Sorry; that was overstated.
(I compared against Fransesco's results.)
Here's the proper comparison.
At least, I thought it was revealing ...
Am I misinterpreting it?
Alan Isaac


###########  script  ################
t1=timeit.Timer('a=sc.empty(shape=10000);a.sort()', 'import scipy.base as sc')
print "Scipy with initialization", min(t1.repeat(30,100))
t2=timeit.Timer('a=na.array(None, shape=10000);a.sort()', 'import numarray as na')
print "numarray with initialization", min(t2.repeat(30,100))
t3=timeit.Timer('a.sort()', 'import scipy.base as sc;a=sc.empty(shape=10000)')
print "Scipy without initialization", min(t3.repeat(30,100))
t4=timeit.Timer('a.sort()', 'import numarray as na;a=na.array(None, shape=10000)')
print "numarray without initialization", min(t4.repeat(30,100))
###########  output  ################
Scipy with initialization 0.300570603247
numarray with initialization 0.177719793996
Scipy without initialization 0.215004420953
numarray without initialization 0.150071587311




More information about the Scipy-dev mailing list