Message84236
_PyLong_AsScaledDouble() writes the exponent in a int which have to be
multiplied by PyLong_SHIFT to give the power of 2. I proposed to
multiply the exponent by PyLong_SHIFT in _PyLong_AsScaledDouble() to
directly get the power of 2. It avoids complex code to test integer
overflow in code using _PyLong_AsScaledDouble() (the test is only done
once, in _PyLong_AsScaledDouble).
I also propose to change exponent type from "int*" to "unsigned int*".
Previous maximum exponent was INT_MAX//PyLong_SHIFT (eg. 143165576 for
PyLong using base 2^15). The new maximum is now
UINT_MAX//PyLong_SHIFT, the double ;-)
And since issue #4258 is commited (Use 30-bit digits instead of 15-bit
digits for Python integers), PyLong_SHIFT value may be different
depending on the compiler option. Using my patch, the long implement
will be a little bit more hidden.
The function _PyLong_AsScaledDouble() should be private because the
name starts with "_". But I see it in Include/longobject.h. In Python,
it's used in longobject.c and mathmodule.c. |
|
Date |
User |
Action |
Args |
2009-03-27 00:23:23 | vstinner | set | recipients:
+ vstinner |
2009-03-27 00:23:22 | vstinner | set | messageid: <1238113402.96.0.541162373186.issue5576@psf.upfronthosting.co.za> |
2009-03-27 00:23:21 | vstinner | link | issue5576 messages |
2009-03-27 00:23:20 | vstinner | create | |
|