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

multiprocessing.Pool is missing a starmap[_async]() method. #56917

Closed
hynek opened this issue Aug 8, 2011 · 11 comments
Closed

multiprocessing.Pool is missing a starmap[_async]() method. #56917

hynek opened this issue Aug 8, 2011 · 11 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@hynek
Copy link
Member

hynek commented Aug 8, 2011

BPO 12708
Nosy @amauryfa, @pitrou, @hynek
Files
  • c02fbcda56f3.diff: Patch to add starmap() and starmap_async() in multiprocessing + tests + docs.
  • 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 = None
    closed_at = <Date 2011-12-21.10:05:02.656>
    created_at = <Date 2011-08-08.08:21:45.954>
    labels = ['type-feature', 'library']
    title = 'multiprocessing.Pool is missing a starmap[_async]() method.'
    updated_at = <Date 2011-12-21.10:05:02.654>
    user = 'https://github.com/hynek'

    bugs.python.org fields:

    activity = <Date 2011-12-21.10:05:02.654>
    actor = 'pitrou'
    assignee = 'none'
    closed = True
    closed_date = <Date 2011-12-21.10:05:02.656>
    closer = 'pitrou'
    components = ['Library (Lib)']
    creation = <Date 2011-08-08.08:21:45.954>
    creator = 'hynek'
    dependencies = []
    files = ['24063']
    hgrepos = ['97']
    issue_num = 12708
    keywords = ['patch']
    message_count = 11.0
    messages = ['141761', '141768', '141935', '141941', '149914', '149916', '149921', '149922', '149923', '149975', '149976']
    nosy_count = 6.0
    nosy_names = ['amaury.forgeotdarc', 'pitrou', 'jnoller', 'neologix', 'python-dev', 'hynek']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue12708'
    versions = ['Python 3.3']

    @hynek
    Copy link
    Member Author

    hynek commented Aug 8, 2011

    After I've seen a co-worker to unpack tuples while using multiprocessing.Pool.map(), I realized that the module is missing a starmap() method like itertools has.

    I took it as a opportunity to contribute some code and implemented both starmap() and starmap_async().

    The patch including tests is attached, please let me know, what you think. Please don't call me names, it's my first patch for such a high profile project like Python. ;)

    @hynek hynek added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Aug 8, 2011
    @hynek
    Copy link
    Member Author

    hynek commented Aug 8, 2011

    In all my excitement, I somehow presumed that the docstring automagically lands in the docs. Added doc entries to patch (I hope they aren't too crude, I'm not a native speaker).

    Same as first patch otherwise.

    @amauryfa
    Copy link
    Member

    +def starmapstar(args):
    + return list(itertools.starmap(args[0], args[1]))

    Is your new function restricted to 2 arguments?

    @hynek
    Copy link
    Member Author

    hynek commented Aug 12, 2011

    No, that's just a helper function like the mapstar directly above. args[1] is the iterable with tuples that get unpacked as arguments.

    @pitrou
    Copy link
    Member

    pitrou commented Dec 20, 2011

    This looks like a reasonable request to me, and the patch looks generally ok as well.

    @pitrou
    Copy link
    Member

    pitrou commented Dec 20, 2011

    One nit: the patch needs "versionadded" tags for the two new functions.

    @hynek
    Copy link
    Member Author

    hynek commented Dec 20, 2011

    Thanks for the feedback Antoine!

    I updated the patch to latest default tip and added the requested tags to the docs.

    @neologix
    Copy link
    Mannequin

    neologix mannequin commented Dec 20, 2011

    Looks good to me, except for another minor nit:
    """
    the elements of the iterable are expected to be tuples
    """

    AFAICT, you just require the elements of ìterables to be iterables, not necessarily tuples.

    @hynek
    Copy link
    Member Author

    hynek commented Dec 20, 2011

    You're right. I've updated the docs accordingly, thanks!

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 21, 2011

    New changeset b07b1e58582d by Antoine Pitrou in branch 'default':
    Issue bpo-12708: Add starmap() and starmap_async() methods (similar to itertools.starmap()) to multiprocessing.Pool.
    http://hg.python.org/cpython/rev/b07b1e58582d

    @pitrou
    Copy link
    Member

    pitrou commented Dec 21, 2011

    Patch committed. Thanks for your contribution!

    @pitrou pitrou closed this as completed Dec 21, 2011
    @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
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants