summaryrefslogtreecommitdiff
path: root/benchmarks/casting.py
blob: cb498db10bc4b93e73d7f9053d7a64c91e7b031a (plain)
1
2
3
4
5
6
7
8
9
import timeit
N = [10,10]
t1 = timeit.Timer('b = a.astype(int)','import numpy;a=numpy.zeros(shape=%s,dtype=float)'%N)
t2 = timeit.Timer('b = a.astype("l")','import Numeric;a=Numeric.zeros(shape=%s,typecode="d")'%N)
t3 = timeit.Timer("b = a.astype('l')","import numarray; a=numarray.zeros(shape=%s,typecode='d')"%N)
print "1-D length = ", N
print "NumPy: ", t1.repeat(3,1000)
print "Numeric: ", t2.repeat(3,1000)
print "Numarray: ", t3.repeat(3,1000)