Python very slow on the Sharp Zaurus - any idea why?

Paul Rubin phr-n2002b at NOSPAMnightsong.com
Mon Jul 22 17:11:42 EDT 2002


Tim Peters <tim.one at comcast.net> writes:
> Python used to use float arithmetic to detect int mult overflow, but that
> didn't work correctly on some 64-bit boxes.
> 
> It got replaced by over 100(!) lines of all-integer int mult
> overflow-checking code, and I believe that's still in 2.1.3.
> 
> But that had an obscure endcase bug too, and it get replaced in 2.2 by a new
> float method that doesn't make unwarranted assumptions about the relative
> sizes of C longs and C doubles, and usually gets out quickly -- provided
> float arithmetic isn't pig slow.

Ouch!!  That doesn't sound so good for the Zaurus.

Is the idea here to discover if a*b overflows 32 bits, if a and b are
32 bit ints?

On compilers supporting 64-bit (long long) ints, it may be faster to
use them instead of floating point for this check.  I think that
includes GCC and current Microsoft compilers among others.  

It may even be ok to synthesize 32-bit multiplication from several
16-bit multiplications, to avoid these overflows.




More information about the Python-list mailing list