Optimizations (was Re: reduce vs. for loop)

Paul Rubin phr-n2002a at nightsong.com
Tue Mar 26 15:24:51 EST 2002


aahz at pythoncraft.com (Aahz) writes:
> Try this:
> 
> def fact3(n):
>     mul = operator.mul
>     return reduce(mul, range(1L, n+1) )

I don't think this is permitted, but if it were,
apply(mul, range(1L, n+1)) would probably be faster than reduce.



More information about the Python-list mailing list