This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: new decumulate() function in itertools module
Type: enhancement Stage: needs patch
Components: Extension Modules Versions: Python 3.4
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: carlo.verre, ezio.melotti, ncoghlan, petri.lehtinen, rhettinger
Priority: low Keywords:

Created on 2011-10-23 22:32 by carlo.verre, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
decumulate.py carlo.verre, 2011-10-23 22:32
Messages (4)
msg146263 - (view) Author: Carlo Verre (carlo.verre) Date: 2011-10-23 22:32
After in Python 3.2 the accumulate() function has been added to itertools module, for self-evident reasons of completeness and symmetry we could add in 3.3 the inverse decumulate() function, which, given the iterable argument p, yields p[0], p[1] - p[0], p[2] - p[1]... Its equivalent python form is in the attached file decumulate.py, below.
msg146290 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2011-10-24 10:45
OK, looking at the code I realised what you're trying to get at is the idea of reporting the differences between values in a series, such that:

x = list(accumulate(seq))
assert x == list(accumulate(differences(x)))

I don't think the use cases are there to justify the addition (not every iterator we can think of should be a building block in itertools), but if such a thing were to be added, "differences" would convey the intention significantly better than the invented term "decumulate".
msg166167 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-07-22 20:29
I don't think this should go in itertools.  It could go in the recipes at the bottom of the itertools doc, if you can provide some valid use cases (and possibly a patch too).
msg168260 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2012-08-15 05:40
I also agree that the itertools module doesn't need this.  (Reasons of "symmetry" are insufficient to make the module fatter that it already is).  In addition, there are already a number of simple ways to do this.
History
Date User Action Args
2022-04-11 14:57:23adminsetgithub: 57461
2012-08-15 05:40:23rhettingersetstatus: open -> closed
resolution: rejected
messages: + msg168260
2012-07-23 04:33:01rhettingersetpriority: normal -> low
assignee: rhettinger
2012-07-22 20:29:18ezio.melottisetversions: + Python 3.4, - Python 3.3
nosy: + ezio.melotti

messages: + msg166167

stage: needs patch
2011-10-24 10:45:04ncoghlansetnosy: + ncoghlan
messages: + msg146290
2011-10-24 06:46:54petri.lehtinensetnosy: + petri.lehtinen
2011-10-23 22:32:47carlo.verrecreate