You should use the built in pow for the python version (or the double asterisk operator). I guess most of the difference with PHP is there.
The type conversion behavior of the math.pow function is clearly documented:
The type conversion behavior of the math.pow function is clearly documented:
Also, I am thinking if and how much speed gain could one inject by not using OOP in PHP...
math.pow() version: 11.7s
pow() version: 6.4s
** version: 5.2s