Jason Nordwick schrieb: > Or without filter: > > from operator import add > def pr(x): print x > def cross(x,y): return reduce(add, [[a+b for b in y] for a in x]) > x=map(pr, reduce(cross, [map(str,range(1,6))]*5)) > [...]
reduce(add, list) is the same as sum(list) and is only half as fast as sum: >>> from timeit import Timer >>> sum(Timer("sum(range(500))").repeat(200, 1000))/200 0.055693786500798058 >>> sum(Timer("reduce(add, range(500))", "from operator import add").repeat(200, 1000))/200 0.10820861031220445 >>> Also note that reduce will be removed in Python 3000. -- http://mail.python.org/mailman/listinfo/python-list