Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:
Here's a pairwise variant: def prod(seq): stack = [] exp = 0 for i, x in enumerate(seq, start=1): m, e = frexp(x) exp += e stack += [m] while not i&1: i >>= 1 x, y = stack[-2:] stack[-2:] = [x * y] total = 1.0 while stack: total *= stack.pop() return ldexp(total, exp) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue41458> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com