Speed comparison of Numeric, numarray, numpy

robert no-spam at no-spam-no-spam.com
Sun Oct 22 07:55:44 CEST 2006


just a note - some speed comparisons :

>>> timeit.Timer('x=a-a*.1','import Numeric;a=Numeric.ones(300,Numeric.Float)').timeit(10000)
0.60627370238398726
>>> timeit.Timer('x=a-a*.1','import numarray;a=numarray.ones(300,numarray.Float)').timeit(10000)
0.42836673376223189
>>> timeit.Timer('x=a-a*.1','import numpy;a=numpy.ones(300,numpy.float)').timeit(10000)
0.36965815487747022

>>> timeit.Timer('x=a[30:40]','import Numeric;a=Numeric.ones(300,Numeric.Float)').timeit(10000)
0.016557970357098384
>>> timeit.Timer('x=a[30:40]','import numarray;a=numarray.ones(300,numarray.Float)').timeit(10000)
0.15692469294117473
>>> timeit.Timer('x=a[30:40]','import numpy;a=numpy.ones(300,numpy.float)').timeit(10000)
0.01951756438393204

>>> timeit.Timer('x=MLab.max(a)','import Numeric,MLab;a=Numeric.ones(300,Numeric.Float)').timeit(10000)
0.21454933518180042
>>> timeit.Timer('x=a.max()','import numarray;a=numarray.ones(300,numarray.Float)').timeit(10000)
0.70624786110965942
>>> timeit.Timer('x=a.max()','import numpy;a=numpy.ones(300,numpy.float)').timeit(10000)
0.21168165227754798

>>> timeit.Timer('x=MLab.max(a[30:40])','import Numeric,MLab;a=Numeric.ones(300,Numeric.Float)').timeit(10000)
0.21775784352394112
>>> timeit.Timer('x=a[30:40].max()','import numarray;a=numarray.ones(300,numarray.Float)').timeit(10000)
0.81516337970242603
>>> timeit.Timer('x=a[30:40].max()','import numpy;a=numpy.ones(300,numpy.float)').timeit(10000)
0.21344193186450866

>>> timeit.Timer('a*=0.99','import Numeric;a=Numeric.ones(300,Numeric.Float)').timeit(10000)
0.293094513410324
>>> timeit.Timer('a*=0.99','import numarray;a=numarray.ones(300,numarray.Float)').timeit(10000)
0.061937480881169904
>>> timeit.Timer('a*=0.99','import numpy;a=numpy.ones(300,numpy.float)').timeit(10000)
0.16990958347923879


strange differences in all directions ...

robert



More information about the Python-list mailing list