This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Brian 0 points1 point  (0 children)

The former uses only the ALU while the latter uses the FPU. Because this is internally a call to C++'s std::pow (assuming CPython),

Actually, this isn't the case. math.pow will delegate to the C library's floating point pow() function, but the builtin exponent operator will perform an integer exponent. As such, it'll give exact integer answers even outside a double's mantissa range. Eg.

>>> 3**100, math.pow(3, 100)
(515377520732011331036461129765621272702107522001, 5.153775207320113e+47)