Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new decumulate() function in itertools module #57461

Closed
carloverre mannequin opened this issue Oct 23, 2011 · 4 comments
Closed

new decumulate() function in itertools module #57461

carloverre mannequin opened this issue Oct 23, 2011 · 4 comments
Assignees
Labels
extension-modules C modules in the Modules dir type-feature A feature request or enhancement

Comments

@carloverre
Copy link
Mannequin

carloverre mannequin commented Oct 23, 2011

BPO 13252
Nosy @rhettinger, @ncoghlan, @ezio-melotti, @akheron
Files
  • decumulate.py
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/rhettinger'
    closed_at = <Date 2012-08-15.05:40:23.091>
    created_at = <Date 2011-10-23.22:32:47.616>
    labels = ['extension-modules', 'type-feature']
    title = 'new decumulate() function in itertools module'
    updated_at = <Date 2012-08-15.05:40:23.090>
    user = 'https://bugs.python.org/carloverre'

    bugs.python.org fields:

    activity = <Date 2012-08-15.05:40:23.090>
    actor = 'rhettinger'
    assignee = 'rhettinger'
    closed = True
    closed_date = <Date 2012-08-15.05:40:23.091>
    closer = 'rhettinger'
    components = ['Extension Modules']
    creation = <Date 2011-10-23.22:32:47.616>
    creator = 'carlo.verre'
    dependencies = []
    files = ['23507']
    hgrepos = []
    issue_num = 13252
    keywords = []
    message_count = 4.0
    messages = ['146263', '146290', '166167', '168260']
    nosy_count = 5.0
    nosy_names = ['rhettinger', 'ncoghlan', 'ezio.melotti', 'petri.lehtinen', 'carlo.verre']
    pr_nums = []
    priority = 'low'
    resolution = 'rejected'
    stage = 'needs patch'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue13252'
    versions = ['Python 3.4']

    @carloverre
    Copy link
    Mannequin Author

    carloverre mannequin commented Oct 23, 2011

    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.

    @carloverre carloverre mannequin added extension-modules C modules in the Modules dir type-feature A feature request or enhancement labels Oct 23, 2011
    @ncoghlan
    Copy link
    Contributor

    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".

    @ezio-melotti
    Copy link
    Member

    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).

    @rhettinger rhettinger self-assigned this Jul 23, 2012
    @rhettinger
    Copy link
    Contributor

    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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    extension-modules C modules in the Modules dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants