Using exponentiation **0.5 less efficient than math.sqrt?
问题 A quote from "Python Programming: An Introduction to Computer Science" We could have taken the square root using exponentiation **. Using math.sqrt is somewhat more efficient. "Somewhat", but to what extent, and how? 回答1: Theoretically, hammar's answer and duffymo's answer are good guesses. But in practice, on my machine, it's not more efficient: >>> import timeit >>> timeit.timeit(stmt='[n ** 0.5 for n in range(100)]', setup='import math', number=10000) 0.15518403053283691 >>> timeit.timeit