2**HUGENUMBER Why not optimise it?

Mike C. Fletcher mcfletch at rogers.com
Thu May 23 01:42:25 EDT 2002


Oh. Sigh.

Maybe I'll just give up on trying to interest people in Python 
optimisation challenges.  The good-old days of idle speculation and 
optimisation are dead.  Time to stop living in the past.  Idea dropped, 
back to boring GUI work.

*poof*

Tim Peters wrote:
> [Mike C. Fletcher]
...
> Why bother?  i**j is performed by a general algorithm that does a number of
> long-int multiplications, but no more than 2*ceiling(log_base_2(j)) of them.
> i==1 is not a special case; it zooms simply because all of the O(log(j))
> intermediate products are exactly 1, so go very quickly.
...
> No, there's simply no point to burning code space to special-case power-of-2
> bases; if you know your base is a power of 2, feel free to shift yourself --
> I do <wink>.
...






More information about the Python-list mailing list