reduce()--what is it good for? (was: Re: reduce() anomaly?)

Georgy Pruss SEE_AT_THE_END at hotmail.com
Mon Nov 10 05:50:20 EST 2003


"Alex Martelli" <aleax at aleax.it> wrote in message news:BsJrb.445840$R32.14865362 at news2.tin.it...
| <...>
| is way faster than "reduce(operator.add, ..." -- and the advantage in
| speed *AND* simplicity grows even more when one considers how often
| that typical reduce is miscoded as "reduce(lambda x, y: x+y, ..." or
| "reduce(int.__add__, ..." and the like.


What's the difference between operator.add and int.__add__?
Why is operator.add faster and "better" than int.__add__ if we deal
with integers?

Georgy


| <...>
|
| Alex
|






More information about the Python-list mailing list