Robin Becker wrote: > Does anyone know if sum does anything special to try and improve accuracy? > My simple tests seem to show it is exactly equivalent to a for loop > summation.
If you are worried about accuracy and your values are floating point numbers
use math.fsum():
"""
fsum(...)
fsum(iterable)
Return an accurate floating point sum of values in the iterable.
Assumes IEEE-754 floating point arithmetic.
"""
--
https://mail.python.org/mailman/listinfo/python-list
