The benefits of having multiple function signatures are optimized compilation times and runtime decisions.
In Python, operation ** looks at its arguments at runtime and decides which algorithm to apply. An integer exponent compared to a rational exponent versus arbitrary indefinite accuracy with unlimited accuracy versus a complex exponent compared to any other. This decision takes time.
In C ++, when the compiler sees pow(x, y) , it knows the x and y types at compile time, so it can choose the best pow() match. This, in turn, allows the compiler to avoid any decision at runtime. Depending on how the headers are written and / or the overall optimization of the program is written, the compiler can even inline the call and avoid any runtime costs other than the actual power calculation.
This usually does not really matter. However, if your pow() call is in a tight loop with millions of iterations, this can be significant.
source share