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

Alun Champion report at bugs.python.org
Mon Nov 2 08:26:47 EST 2015


Alun Champion added the comment:

Understandable, though it would have also made the first order recurrence relationships more accurate, e.g. annualized interest on an initial balance:

    accumulate(repeat(None), lambda: bal, _: bal*1.05, initializer=1000)

vs. artificially repeating 1000:

    accumulate(repeat(1000), lambda: bal, _: bal*1.05)

Or, if the initialiser is expensive:

    accumulate(chain([1000], repeat(None)), lambda: bal, _: bal*1.05)

----------

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


More information about the Python-bugs-list mailing list