best cumulative sum
aisaac0 at verizon.net
Wed Nov 23 17:51:41 CET 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, ) == cumreduce(f, , 1)
> cumreduce(f, ) == cumreduce(f, , 0)
> Of course nothing can beat a plain old for loop in terms of readability
> -- most likely -- speed.
More information about the Python-list