[Python-Dev] [Python-checkins] cpython: Add optional *func* argument to itertools.accumulate().
Raymond Hettinger
raymond.hettinger at gmail.com
Mon Mar 28 09:49:03 CEST 2011
More information about the Python-Dev mailing list
Mon Mar 28 09:49:03 CEST 2011
- Previous message: [Python-Dev] [Python-checkins] cpython: Add optional *func* argument to itertools.accumulate().
- Next message: [Python-Dev] [Python-checkins] cpython: Add optional *func* argument to itertools.accumulate().
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mar 28, 2011, at 12:38 AM, Daniel Stutzbach wrote: > On Sun, Mar 27, 2011 at 10:53 PM, Nick Coghlan <ncoghlan at gmail.com> wrote: > On Mon, Mar 28, 2011 at 2:11 PM, Daniel Stutzbach <stutzbach at google.com> wrote: > > Is there a good use-case for the func argument? > > The examples that Raymond gives in the docs (cumulative > multiplication, running min/max, cash flow accumulation) look fairly > solid to me. > > (I had the nagging suspicion that I was making a blunder in my email, but I couldn't see it despite rereading my email several times before sending. My blunder was in not rereading the patch to see the examples. Anyway...) > > When would a running product, min, or max be useful? There's no need to speculate. This API has long been present in other languages and libraries. Do a google code search for R's builtin functions cumsum, cumprod, cummin, and cummax. Look at mumpy's accumulate ufunc which works with many operators. APL and K also have an accumulate tool which takes arbitrary functions. Or consider as an API principle that there should be s useful default (addition in this case) and also hooks or parameters provided so that users don't have to do backflips to override hard-wired behaviors. Raymond -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20110328/49d7958e/attachment.html>
- Previous message: [Python-Dev] [Python-checkins] cpython: Add optional *func* argument to itertools.accumulate().
- Next message: [Python-Dev] [Python-checkins] cpython: Add optional *func* argument to itertools.accumulate().
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list