Russ wrote: > I have a couple of questions for the number crunchers out there: > > Does "pow(x,2)" simply square x, or does it first compute logarithms > (as would be necessary if the exponent were not an integer)? > > Does "x**0.5" use the same algorithm as "sqrt(x)", or does it use some > other (perhaps less efficient) algorithm based on logarithms?
you can try and timeit >>> 111**111 107362012888474225801214565046695501959850723994224804804775911175625076195783347022491226170093634621466103743092986967777786330067310159463303558666910091026017785587295539622142057315437069730229375357546494103400699864397711L >>> timeit.Timer("pow(111,111)").timeit() 40.888447046279907 >>> timeit.Timer("111**111").timeit() 39.732122898101807 >>> timeit.Timer("111**0.5").timeit() 2.0990891456604004 >>> timeit.Timer("pow(111,0.5)").timeit() 4.1776390075683594 >>> timeit.Timer("111**0.3").timeit() 2.3824679851531982 >>> timeit.Timer("pow(111,0.3)").timeit() 4.2945041656494141 interesting result seems that ** computates faster -- http://mail.python.org/mailman/listinfo/python-list