Message408094
Hmm, I had just looked at that code and it wasn't at all obvious that an optimization had been added. I expected something like:
if (exp==2) return PyNumber_Multiply(x, x);
I wonder where the extra clock cycles are going. Looking at the ceval.c dispatch and the bodies of PyNumber_Multiply(), _PyNumber_PowerNoMod(), and PyNumber_Power(), it looks like the power dispatch code should be about the same as or slightly cheaper than the multiply dispatch.
I'm surprised there is still almost a two to one speed difference. ISTM there is still too much overhead for squaring. |
|
Date |
User |
Action |
Args |
2021-12-09 09:37:00 | rhettinger | set | recipients:
+ rhettinger, mark.dickinson, Dennis Sweeney |
2021-12-09 09:37:00 | rhettinger | set | messageid: <1639042620.65.0.398711039534.issue46020@roundup.psfhosted.org> |
2021-12-09 09:37:00 | rhettinger | link | issue46020 messages |
2021-12-09 09:37:00 | rhettinger | create | |
|