Message414144
My example used ints, but I was being deliberately vague when I said "bignums". Balanced-tree reduction certainly isn't optimal for ints, and may not be optimal for anything, but it's pretty good for a lot of things. It's the comparison-based sorting of reduction algorithms.
* When the inputs are of similar sizes, it tends to produce intermediate operands of similar sizes, which helps with Karatsuba multiplication (as you said).
* When the inputs are of different sizes, it limits the "damage" any one of them can do, since they only participate in log2(n) operations each.
* It doesn't look at the values, so it works with third-party types that are unknown to the stdlib.
There's always a fallback case, and balanced reduction is good for that. If there's a faster path for ints that looks at their bit lengths, great. |
|
Date |
User |
Action |
Args |
2022-02-27 08:36:09 | benrg | set | recipients:
+ benrg, tim.peters, rhettinger, mark.dickinson |
2022-02-27 08:36:09 | benrg | set | messageid: <1645950969.76.0.924703679546.issue46868@roundup.psfhosted.org> |
2022-02-27 08:36:09 | benrg | link | issue46868 messages |
2022-02-27 08:36:09 | benrg | create | |
|