infectedsoundsystem/pyffi — comment on commit e8ed13e4bb8d035655a77585eaecaf16a4a1410a
File:  line 0
By amorilia:

Thanks for this, but are you sure about it? It's perhaps very odd, and maybe I'm too quick to conclude, but a quit test seems to show that ** 0.5 is almost 4 times faster than math.sqrt:

$ python -m timeit -n 1000000 "10 ** 0.5"
1000000 loops, best of 3: 0.0273 usec per loop
$ python -m timeit -n 1000000 --setup="from math import sqrt" "sqrt(10)"
1000000 loops, best of 3: 0.105 usec per loop

It's even worse under Python 3:

$ python3 -m timeit -n 1000000 "10 ** 0.5"
1000000 loops, best of 3: 0.0289 usec per loop
$ python3 -m timeit -n 1000000 --setup="from math import sqrt" "sqrt(10)"
1000000 loops, best of 3: 0.16 usec per loop

I'm not sure what's going on here. My guess is that ** 0.5 avoids a function call.