Re: [Tutor] finding square roots

2007-10-05 Thread wesley chun
oddly enough, i get different results doing it the "old-fashioned" way: $ sqrt.py using ** 0.000447034835815 using sqrt() 0.000399112701416 $ sqrt.py using ** 0.00043797492981 using sqrt() 0.000399827957153 $ sqrt.py using ** 0.00043797492981 using sqrt() 0.000402927398682 here's the code snipp

Re: [Tutor] finding square roots

2007-10-05 Thread Alan Gauld
"Eric Brunson" <[EMAIL PROTECTED]> wrote >> t = timeit.Timer( "sqrt(12)", "from math import sqrt" ) >> print t.timeit(1000) >>> 7.17679214478 > timeit.Timer("import math; math.sqrt(64)").timeit(1000) >> 0.002298138362618829 > timeit.Timer("import math; 64 ** 0.5").timeit(1000

Re: [Tutor] finding square roots

2007-10-05 Thread Eric Brunson
Alan Gauld wrote: > "Eric Brunson" <[EMAIL PROTECTED]> wrote > > > import timeit > t = timeit.Timer( "12 ** .5" ) > print t.timeit(1000) > >> 2.29147315025 >> > t = timeit.Timer( "sqrt(12)", "from math import sqrt" ) > print t.timeit(1000) >

Re: [Tutor] finding square roots

2007-10-05 Thread Alan Gauld
"Eric Brunson" <[EMAIL PROTECTED]> wrote > >>> import timeit > >>> t = timeit.Timer( "12 ** .5" ) > >>> print t.timeit(1000) > 2.29147315025 > >>> t = timeit.Timer( "sqrt(12)", "from math import sqrt" ) > >>> print t.timeit(1000) > 7.17679214478 > > Looks like ** is about three times fast

Re: [Tutor] finding square roots

2007-10-05 Thread Eric Brunson
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(1000) 2.29147315025 >>> t = timeit.Timer( "sqrt(

[Tutor] finding square roots

2007-10-05 Thread Elaine
Does anyone know which is the more efficient way of finding a square root in Python: sqrt(x) or x ** 0.5 ??? Thanks, Elaine Building a website is a piece of cake. Yahoo! Small Busin