subexpressions

Steve Howell showell30 at yahoo.com
Fri Jun 1 18:59:11 CEST 2007


--- "Diez B. Roggisch" <deets at nospam.web.de> wrote:
> The elegance of that solution very much depends on
> the cost of the duplicate
> operation vs. the additional function call.
> 
> And for the usecase at hand, that's exactly the
> point not to do it:
> 
> droggisch at ganesha:/tmp$ python -m timeit '(lambda x:
> lambda y: y+y)(10 *
> 10)'
> 1000000 loops, best of 3: 1.04 usec per loop
> droggisch at ganesha:/tmp$ python -m timeit 'lambda: 10
> * 10 + 10 * 10'
> 1000000 loops, best of 3: 0.336 usec per loop
> 

Good point.  I also realized as I was slowly waking up
later in the morning that the trigonometry didn't make
a whole lot of sense either.




       
____________________________________________________________________________________
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more. 
http://mobile.yahoo.com/go?refer=1GNXIC



More information about the Python-list mailing list