Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:
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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46020> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com