[Python-checkins] benchmarks: Force map to a list to guarantee the calculations are performed under
brett.cannon
python-checkins at python.org
Mon Oct 1 01:00:42 CEST 2012
http://hg.python.org/benchmarks/rev/e9f911fd9bd3
changeset: 184:e9f911fd9bd3
user: Brett Cannon <brett at python.org>
date: Sun Sep 30 19:00:32 2012 -0400
summary:
Force map to a list to guarantee the calculations are performed under
Python 3.
files:
performance/bm_spectral_norm.py | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/performance/bm_spectral_norm.py b/performance/bm_spectral_norm.py
--- a/performance/bm_spectral_norm.py
+++ b/performance/bm_spectral_norm.py
@@ -11,14 +11,14 @@
import itertools
import optparse
-from compat import izip, xrange
+from compat import imap, izip, xrange
import util
def eval_A(i, j):
- return 1.0 / ((i + j) * (i + j + 1) / 2 + i + 1)
+ return 1.0 / ((i + j) * (i + j + 1) // 2 + i + 1)
def eval_times_u(func, u):
- return map(func, ((i,u) for i in xrange(len(list(u)))))
+ return list(imap(func, ((i,u) for i in xrange(len(list(u))))))
def eval_AtA_times_u(u):
return eval_times_u(part_At_times_u, eval_times_u(part_A_times_u, u))
@@ -57,7 +57,7 @@
tk = time.time()
times.append(tk - t0)
return times
-
+
if __name__ == "__main__":
parser = optparse.OptionParser(
usage="%prog [options]",
--
Repository URL: http://hg.python.org/benchmarks
More information about the Python-checkins
mailing list