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

2015-11-02 Thread Alun Champion
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

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

2015-10-25 Thread Alun Champion
Alun Champion added the comment: If you are looking for other examples. Here's a wheel factorization of an indefinite sieve (primes) that was peer reviewed on codereview.stackexchange.com, see the final result in the last post by Will Ness: http://codereview.stackexchange.com/questions/

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

2015-09-20 Thread Alun Champion
New submission from Alun Champion: itertools.accumulate should have an initializer with the same semantics as functools.reduce. These two functions are closely related, reduce only providing you the end result accumulate providing an iterator over all the intermediate results. However, if you

[issue25192] deque append and appendleft should return value if maxlen set

2015-09-20 Thread Alun Champion
New submission from Alun Champion: Currently if you append or appendleft when len(deque) == maxlen item from the other end of the deque is discarded. These should return the discarded value to allow you to write: x = deque.append(y) vs if len(deque) == deque.maxlen(): x