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 [*].
It also decreases memory requirements for intermediate buffer on 10%. The size of intermediate buffer (in digits) depends on the size of the integer. Unpatched: For 15-bit digits: size*15/4/3 = size*1.25 For 30-bit digits: size*30/9/3 = size*1.11 Patched: For 15-bit digits: size*15/4/3.3 = size*1.14 For 30-bit digits: size*30/9/3.3 = size*1.01 [*] Converting such large integers to decimal string can be not finished for reasonable time, because it has quadratic complexity. On my netbook the estimated time of calculating str(2**2**31) is 5 years. But this is different issue. ---------- components: Interpreter Core files: long_to_decimal_string_number_of_digits.patch keywords: patch messages: 252985 nosy: mark.dickinson, serhiy.storchaka priority: normal severity: normal stage: patch review status: open title: Accurater estimation of the number of digits in int to decimal string conversion type: behavior versions: Python 3.6 Added file: http://bugs.python.org/file40782/long_to_decimal_string_number_of_digits.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25402> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com