Microbenchmark: Summing over array of doubles

Christopher T King squirrel at WPI.EDU
Mon Aug 2 00:47:34 CEST 2004

On 1 Aug 2004, Duncan Booth wrote:

> I just had a brief look at the code you posted. Are you not concerned about 
> accuracy in any of your calculations? Summing a 10 million element array by 
> simply accumulating each element into a running total is guaranteed to give 
> a lousy result.

Lousy or not, I believe that's how numarray is implemented internally, so
at least all the benchmarks are the same.  If you want accuracy summing
that many numbers, you're going to have to do it in software (likely by
summing each mantissa bit individually and reconstructing the float
afterward), so it will be abysmally slow (obviously not what the OP

More information about the Python-list mailing list