[issue25402] Accurater estimation of the number of digits in int to decimal string conversion

2015-10-15 Thread STINNER Victor
Changes by STINNER Victor : -- nosy: +haypo ___ Python tracker ___ ___

[issue25402] Accurater estimation of the number of digits in int to decimal string conversion

2015-10-15 Thread STINNER Victor
STINNER Victor added the comment: Currently, the code uses Py_ABS(Py_SIZE(x))*PyLong_SHIFT to estimate the upper-bound of the number of bits of the number x. It's a raw estimation, the difference can be up to 29 bits. We may try to compute the exact number of bits, x.bit_length(). Python 3.5

[issue25402] Accurater estimation of the number of digits in int to decimal string conversion

2015-10-15 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > But why only using 2 digits for log2(10) estimation? Because the difference between 3 and 3.3 is 10%, and the difference between 3.3 and exact log2(10) is only 1%. Yes, we can use more digits, but the effect of any additional digit is decreased in

[issue25402] Accurater estimation of the number of digits in int to decimal string conversion

2015-10-14 Thread Serhiy Storchaka
New submission from Serhiy Storchaka: Int to decimal string conversion (function long_to_decimal_string_internal() at Objects/longobject.c:1583) has a limitation. On 32-bit platform you can't convert integers larger than 2**2**31 (10**646456993). Proposed patch removes this limitation [*].