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 rhettinger
Recipients PedanticHacker, Stefan Pochmann, mark.dickinson, mcognetta, rhettinger, serhiy.storchaka, tim.peters
Date 2022-01-12.23:19:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1642029562.75.0.425629230923.issue37295@roundup.psfhosted.org>
In-reply-to
Content
ISTM that the asymptotic benefits of Karatsuba multiplication are mostly lost when each of the factors has to be built-up recursively prior to the multiply.  Also, the benefits of Karatsuba only start to appear at around 400-bit numbers.  For us, we don't get there until comb(400, 200).  Even there, almost all of the multiplications are with smaller values that get no benefit at all from Karatsuba multiplication.  IOW, I don't think Karatsuba multiplication has been helping at all.  More likely, the improvement came from a reduced number of divisions.

The depth issue is a red herring.  The fixed j approach is only used up to n=235.¹  The largest input, comb(235, 117), recurses only five levels C(215,97), C(195,77),
 C(175,57), C(155,37), C(135,17) before handing off to the j=k//2 algorithm.  Five levels of width one is so inexpensive that it isn't worth talking about, especially when considering how many PyLong multiplies and divides are saved.²


¹ Jlim = 235 in the posted comb_pole.py.  I've since changed the span of precomputed combinations to C(n, 20) where 87 ≤ n ≤ 250.

² See the trace in the previous post showing a seven-fold reduction in the number of PyLong multiply and divide operations.
History
Date User Action Args
2022-01-13 00:23:59rhettingerunlinkissue37295 messages
2022-01-12 23:19:22rhettingersetrecipients: + rhettinger, tim.peters, mark.dickinson, serhiy.storchaka, PedanticHacker, mcognetta, Stefan Pochmann
2022-01-12 23:19:22rhettingersetmessageid: <1642029562.75.0.425629230923.issue37295@roundup.psfhosted.org>
2022-01-12 23:19:22rhettingerlinkissue37295 messages
2022-01-12 23:19:22rhettingercreate