"Mike Ressler" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have a counterexample. In the original timeit example, 111**111 was > used. When I run that > >>>> timeit.Timer("pow(111,111)").timeit() > 10.968398094177246 >>>> timeit.Timer("111**111").timeit() > 10.04007887840271 >>>> timeit.Timer("111.**111.").timeit() > 0.36576294898986816 > > The pow and ** on integers take 10 seconds, but the float ** takes only > 0.36 seconds. (The pow with floats takes ~ 0.7 seconds). Clearly > typecasting to floats is coming in here somewhere. (Python 2.4.1 on > Linux FC4.)
For floats, f**g == exp(log(f**g)) == exp(g*log(f)) (with maybe further algebraic manipulation, depending on the implementation). The time for this should only be mildly dependent on the magnitudes of f and g. The time for i**j, on the other hand, grows at least as fast as log(j). So I should expect comparisons to depend on magnitudes, as you discovered. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list