reduce()--what is it good for? (was: Re: reduce() anomaly?)
Erik Max Francis
max at alcyone.com
Fri Nov 7 12:35:53 CET 2003
Alex Martelli wrote:
> Yeah, I know, speed isn't everything. But when the speed of a
> analogous operation drops by two times (from reduce to sum) or even
> more when it drops by 50 times (from reduce on a list to Numeric.add.
> reduce on a Numeric.array) one _does_ get a sense of when one's using
> a language "reasonably idiomatically" -- within the design space of
> language, within the pathways most often taken by the language's best
> practitioners and therefore most likely to be solid and optimized.
But reduce isn't simply intended for adding up numbers. It's for doing
any kind of reduction.
Yes, I'm sure specific reductions based on summing are faster than using
reduce. But that goes without saying. Furthermore, Numeric is not
builtin to Python, so that seems a red herring to me. Either you should
compare builtins to builtins, or not.
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ Every time a friend succeeds, I die a little.
\__/ Gore Vidal
More information about the Python-list