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 tim.peters
Recipients Carl.Friedrich.Bolz, Dennis Sweeney, tim.peters
Date 2022-01-31.05:27:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1643606839.65.0.9946336645.issue46558@roundup.psfhosted.org>
In-reply-to
Content
The factorial of a million is much smaller than the case I was looking at. Here are rough timings on my box, for computing the decimal string from the bigint (and, yes, they all return the same string):

native:   475    seconds (about 8 minutes)
numeral:   22.3  seconds
todecstr:   4.10 seconds
gmp:        0.74 seconds

"They recursively split the bigint into halves using % 10^n at each recursion step". That's the standard trick for "output" conversions. Beyond that, there are different ways to try to use "fat" multiplications instead of division. The recursive splitting all on its own can help, but dramatic speedups need dramatically faster multiplication.

todecstr treats it as an "input" conversion instead, using the `decimal` module to work mostly _in_ base 10. That, by itself, reduces the role of division (to none at all in the Python code), and `decimal` has a more advanced multiplication algorithm than CPython's bigints have.
History
Date User Action Args
2022-01-31 05:27:19tim.peterssetrecipients: + tim.peters, Carl.Friedrich.Bolz, Dennis Sweeney
2022-01-31 05:27:19tim.peterssetmessageid: <1643606839.65.0.9946336645.issue46558@roundup.psfhosted.org>
2022-01-31 05:27:19tim.peterslinkissue46558 messages
2022-01-31 05:27:19tim.peterscreate