On Mar 28, 10:17 am, Duncan Booth <duncan.bo...@invalid.invalid> wrote: > Doing add-in-place isn't the only way to make sum more efficient: if you > assume that addition is associative (which of course the builtin sum can't) > then you can form partial sums. e.g. instead of calculating: ... > > Doing it this way helps summing lists or strings (though not as much as > str.join), but it also helps if you need to sum a long list of similarly > sized floats as you'll get a more accurate answer.
Also, partial sums would be a clear winner over add-in-place if someone were dumb^H^H^H^Hnaive enough to use sum() on a long list of tuples :-) -- http://mail.python.org/mailman/listinfo/python-list