Commits

Brett Cannon committed e9f911f

Force map to a list to guarantee the calculations are performed under
Python 3.

  • Participants
  • Parent commits ea0b385

Comments (0)

Files changed (1)

File performance/bm_spectral_norm.py

 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))
         tk = time.time()
         times.append(tk - t0)
     return times
-    
+
 if __name__ == "__main__":
     parser = optparse.OptionParser(
         usage="%prog [options]",