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 Dennis Sweeney, mark.dickinson, rhettinger
Date 2021-12-09.09:37:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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:00rhettingersetrecipients: + rhettinger, mark.dickinson, Dennis Sweeney
2021-12-09 09:37:00rhettingersetmessageid: <>
2021-12-09 09:37:00rhettingerlinkissue46020 messages
2021-12-09 09:37:00rhettingercreate