[Scipy-svn] r4518 - trunk/scipy/sandbox/mkufunc/examples
scipy-svn@scip...
scipy-svn@scip...
Tue Jul 1 16:56:13 CDT 2008
Author: ilan
Date: 2008-07-01 16:56:12 -0500 (Tue, 01 Jul 2008)
New Revision: 4518
Modified:
trunk/scipy/sandbox/mkufunc/examples/benchmark.py
Log:
Using empty_like is much faster than .copy()
Modified: trunk/scipy/sandbox/mkufunc/examples/benchmark.py
===================================================================
--- trunk/scipy/sandbox/mkufunc/examples/benchmark.py 2008-07-01 21:38:28 UTC (rev 4517)
+++ trunk/scipy/sandbox/mkufunc/examples/benchmark.py 2008-07-01 21:56:12 UTC (rev 4518)
@@ -2,7 +2,7 @@
from math import sin, cos
import time, hashlib
-from numpy import arange, vectorize, allclose
+from numpy import arange, vectorize, allclose, empty_like
from scipy import weave
from mkufunc.api import mkufunc
@@ -75,7 +75,7 @@
x = arange(0, 1000, 0.0001) #print "x =", x, x.dtype
start_time = time.time()
-b_y = x.copy()
+b_y = empty_like(x)
weave.blitz("b_y[:] = 4.2 * x[:] * x[:] + 3.7 * x[:] + 1.5")
b_time = time.time() - start_time
print 'blitz: %.6f sec' % b_time
More information about the Scipy-svn
mailing list