Elaine wrote: > Does anyone know which is the more efficient way of > finding a square root in Python: > > sqrt(x) or x ** 0.5 >
I dunno, let's check: >>> import timeit >>> t = timeit.Timer( "12 ** .5" ) >>> print t.timeit(10000000) 2.29147315025 >>> t = timeit.Timer( "sqrt(12)", "from math import sqrt" ) >>> print t.timeit(10000000) 7.17679214478 Looks like ** is about three times faster than sqrt(), but that could be the function overhead. > ??? > > Thanks, > Elaine > > > > ____________________________________________________________________________________ > Building a website is a piece of cake. Yahoo! Small Business gives you all > the tools to get online. > http://smallbusiness.yahoo.com/webhosting > _______________________________________________ > Tutor maillist - [email protected] > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
