best cumulative sum
David Isaac
aisaac0 at verizon.net
Wed Nov 23 11:51:41 EST 2005
"Peter Otten" <__peter__ at web.de> wrote in message
news:dm263o$b8b$02$1 at news.t-online.com...
> - allows arbitrary iterables, not sequences only
> - smaller memory footprint if sequential access to the items is sufficient
Sure; I meant aside from that.
> - fewer special cases, therefore
> - less error prone, e. g.
> + does your implementation work for functions with
> f(a, b) != f(b, a)?
See news:Mzpgf.12794$NN2.4089 at trnddc02
> + won't users be surprised that
> cumreduce(f, [1]) == cumreduce(f, [], 1)
> !=
> cumreduce(f, [0]) == cumreduce(f, [], 0)
THANKS!
> Of course nothing can beat a plain old for loop in terms of readability
and
> -- most likely -- speed.
OK.
Thanks,
Alan Isaac
More information about the Python-list
mailing list