Optimizations (was Re: reduce vs. for loop)

oivvio at polite.se oivvio at polite.se
Tue Mar 26 10:26:58 EST 2002


On Tue, Mar 26, 2002 at 10:05:19AM -0500, Aahz wrote:
> 
> def fact3(n):
>     mul = operator.mul
>     return reduce(mul, range(1L, n+1) )

faster than fact1 slower than fact2

> 
> "We should forget about small efficiencies, about 97% of the time.
> Premature optimization is the root of all evil."  --Knuth
I know. I was just  curious :) 



-- 
oivvio polite
cell +46 (0)709 30 40 30 / phone +46 (0)8 669 64 18 / fax +46 (0)8 84 00 18
varvsgatan 10A / s-117 29 stockholm / sweden




More information about the Python-list mailing list