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

Improve itertools.starmap #43440

Closed
collinwinter mannequin opened this issue May 31, 2006 · 8 comments
Closed

Improve itertools.starmap #43440

collinwinter mannequin opened this issue May 31, 2006 · 8 comments
Assignees
Labels
extension-modules C modules in the Modules dir

Comments

@collinwinter
Copy link
Mannequin

collinwinter mannequin commented May 31, 2006

BPO 1498370
Nosy @rhettinger, @jackdied
Files
  • better_starmap.patch: Improve itertools.startmap(), against r47103
  • 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 2009-01-27.05:14:58.369>
    created_at = <Date 2006-05-31.17:41:09.000>
    labels = ['extension-modules']
    title = 'Improve itertools.starmap'
    updated_at = <Date 2009-01-27.05:14:58.368>
    user = 'https://bugs.python.org/collinwinter'

    bugs.python.org fields:

    activity = <Date 2009-01-27.05:14:58.368>
    actor = 'rhettinger'
    assignee = 'rhettinger'
    closed = True
    closed_date = <Date 2009-01-27.05:14:58.369>
    closer = 'rhettinger'
    components = ['Extension Modules']
    creation = <Date 2006-05-31.17:41:09.000>
    creator = 'collinwinter'
    dependencies = []
    files = ['7299']
    hgrepos = []
    issue_num = 1498370
    keywords = ['patch']
    message_count = 8.0
    messages = ['50390', '50391', '50392', '50393', '50394', '50395', '50396', '80621']
    nosy_count = 5.0
    nosy_names = ['anthonybaxter', 'collinwinter', 'rhettinger', 'quiver', 'jackdied']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1498370'
    versions = ['Python 2.5']

    @collinwinter
    Copy link
    Mannequin Author

    collinwinter mannequin commented May 31, 2006

    As it currently stands, the iterator argument to
    itertools.starmap() must yield tuples, even those any
    iterable can be *-expanded in function calls. The
    attached patch changes starmap()'s behaviour (as well
    as docs and tests) to allow the provided iterator to
    return any iterable object.

    The patch is against r46582.

    @collinwinter collinwinter mannequin added the extension-modules C modules in the Modules dir label May 31, 2006
    @collinwinter collinwinter mannequin added the extension-modules C modules in the Modules dir label May 31, 2006
    @quiver
    Copy link
    Mannequin

    quiver mannequin commented Jun 1, 2006

    Logged In: YES
    user_id=671362

    @jackdied
    Copy link
    Contributor

    jackdied commented Jun 9, 2006

    Logged In: YES
    user_id=591932

    The patch can be simplified by always calling
    PySequence_Tuple() and doing the decref instead of special
    casing tuples. If you pass PySequence_Tuple() a tuple it
    will incref it and hand it back to you.

    @collinwinter
    Copy link
    Mannequin Author

    collinwinter mannequin commented Jun 27, 2006

    Logged In: YES
    user_id=1344176

    I've updated the patch per jackdied's suggestion, plus
    improved the test suite a bit.

    The patch is now against r47103.

    @rhettinger
    Copy link
    Contributor

    Logged In: YES
    user_id=80475

    Since starmap() is documented to behave like "yield
    function(*iterable.next())", I think this fixup can be
    considered a bugfix. If Anthony is okay with this, it
    should into Py2.5.

    While Jack's suggested modification leads to a
    conceptually simpler patch, I prefer an alternate version
    that only calls PySequence_Tuple() if PyTuple_CheckExact()
    fails. That will make sure that we don't slow down the
    most common case.

    Also, I prefer slightly different updates to the docs and
    test suite. If Anthony approves for inclusion in Py2.5, I
    will upload my own version of a patch to starmap().

    @jackdied
    Copy link
    Contributor

    Logged In: YES
    user_id=591932

    Raymond's intuition for bare metal is correct. My suggested
    simplifaction slowed down the tuple case by most of a
    percent (I benchmarked it but left it out of the comment).
    Preternatural, I tell you.

    @anthonybaxter
    Copy link
    Mannequin

    anthonybaxter mannequin commented Jul 25, 2006

    Logged In: YES
    user_id=29957

    Hm. Making the code agree with the docs is a good plan.
    Please make sure to include a very clear NEWS item.

    @rhettinger
    Copy link
    Contributor

    This was fixed in r60013.

    @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
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants