[issue25193] itertools.accumulate should have an optional initializer argument

Raymond Hettinger report at bugs.python.org
Sun Oct 25 23:44:08 EDT 2015


Raymond Hettinger added the comment:

To me prime sieve demos and puzzle problems aren't motivating use cases.  Also, the two examples in the single stack-exchange answer become awkward because they would also need a middle argument for the accumulation function:

Current:
  cs = accumulate(chain([11], cycle(wh11)))
  wheel = accumulate(chain([psq+x[i]], cycle(x[i+1:] + x[:i+1])))

Proposed:
  cs = accumulate(cycle(wh11), operator.add, 11)
  wheel = accumulate(cycle(x[i+1:] + x[:i+1]), operator.add, psq+x[i])

IMO both of the newer ones are wordier, don't read well, and are slower.  

After more thought, I've decided to stick with the original decision and decline the feature request.  There are other major languages that seem to do fine without the feature, the current approach works fine, my search for possible use cases shows that they are uncommon or contrived, and looking at the revised examples I just don't think that the newer code reads well.

----------
resolution:  -> rejected
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25193>
_______________________________________


More information about the Python-bugs-list mailing list