This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients vstinner
Date 2009-03-27.00:23:17
SpamBayes Score 3.0725422e-13
Marked as misclassified No
Message-id <1238113402.96.0.541162373186.issue5576@psf.upfronthosting.co.za>
In-reply-to
Content
_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.
History
Date User Action Args
2009-03-27 00:23:23vstinnersetrecipients: + vstinner
2009-03-27 00:23:22vstinnersetmessageid: <1238113402.96.0.541162373186.issue5576@psf.upfronthosting.co.za>
2009-03-27 00:23:21vstinnerlinkissue5576 messages
2009-03-27 00:23:20vstinnercreate