Closed Sbozzolo closed 3 years ago
Before this commit, pow was the only binary function that doesn't use the corresponding operator but calls pow in math. This commit defines a pow function that invokes the corresponding operator (**).
pow
math
Using ** is preferable because it is slightly faster and preservers integers (see, https://www.semicolonworld.com/question/56223/exponentials-in-python-x-y-vs-math-pow-x-y). Moreover, it improves type compatibility, since now the function works with user-defined classes (as long as they have a __pow__ method), math.pow only supports numbers.
__pow__
math.pow
@cansadadeserfeliz, any thought of this?
✅ @Sbozzolo thanks!
Before this commit,
pow
was the only binary function that doesn't use the corresponding operator but callspow
inmath
. This commit defines apow
function that invokes the corresponding operator (**).Using ** is preferable because it is slightly faster and preservers integers (see, https://www.semicolonworld.com/question/56223/exponentials-in-python-x-y-vs-math-pow-x-y). Moreover, it improves type compatibility, since now the function works with user-defined classes (as long as they have a
__pow__
method),math.pow
only supports numbers.