gh-102221: Optimize math.integer.lcm() for multiple arguments (non-recursive)#135609
gh-102221: Optimize math.integer.lcm() for multiple arguments (non-recursive)#135609serhiy-storchaka wants to merge 4 commits intopython:mainfrom
Conversation
792d234 to
26d961e
Compare
26d961e to
78731c0
Compare
How common it is? Where the cutoff when this version will payoff us it's complexity over #135554? |
|
I did not measure it. But estimation for #135554 on abstract machine is 6 words/level (return address, two parameters and three local variables), so this is 6 and 11 on 32- and 64-bit platforms. Or 64 and 2048 arguments correspondingly. It may be less if recursion needs more than just a return address or larger if the compiler is extra clever in reusing stack variable. The maximal stack consumption of this version is 8*64=512 bytes for the stack variable, plus up to 64 byte for other variables/parameters (but registers can be used for many of them). In #135554 it can be about 3KB in worst case. |
|
This PR is stale because it has been open for 30 days with no activity. |
This version uses manually supported stack instead of the C stack. It has less C stack consumption for very large number of arguments. But for not such large number of arguments (thousands or millions) it may actually have larger C stack consumption.