diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-06-27 22:08:07 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-06-27 22:08:07 +0000 |
commit | 36c72bfc2118e52160d3445e06b6e1cc17a2cba7 (patch) | |
tree | 5ab06939e7e4d7dc8fed3534f0d12a2fcc5e9e00 /benchmarks/casting.py | |
parent | 47c92e4224ee36090289fcafa6820f749bc3d9b1 (diff) | |
download | numpy-36c72bfc2118e52160d3445e06b6e1cc17a2cba7.tar.gz |
Add a function to retrieve a user-defined type number from the name of the associated type-object
Diffstat (limited to 'benchmarks/casting.py')
-rw-r--r-- | benchmarks/casting.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/benchmarks/casting.py b/benchmarks/casting.py new file mode 100644 index 000000000..84558a088 --- /dev/null +++ b/benchmarks/casting.py @@ -0,0 +1,9 @@ +import timeit +N = [1000,100] +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,100) +print "Numeric: ", t2.repeat(3,100) +print "Numarray: ", t3.repeat(3,100) |