Poor floating point performance? I wrote the following simple loop which uses floating point arithmetic to sum the squares of the integers from 0 to 1.0e9 - 1:

    a = 0.0
    i = 0.0
    while i &lt; 1.0e9:
        a += i * i
        i += 1.0
    print a

On my machine, using 32-bit CPython 2.7.8, this takes 400 seconds to run. The equivalent C++ code (below) runs in less than 2 seconds and the equivalent Go code in less than 3.

    double a = 0.0;
    for(double i = 0.0; i &lt; 1.0e9; i += 1.0) {
        a += i * i;
    }
    std::cout &lt;&lt; a &lt;&lt; std::endl;

It appears that Python's floating point performance is only 1% of that of some other languages!

I would love to use Python (and its rich ecosystem) for my arithmetic-heavy projects, but it is simply not an option if it means that these programs will take 100 times as long to run! Is there anything I can do about this poor performance?