msg141761 - (view) |
Author: Hynek Schlawack (hynek) *  |
Date: 2011-08-08 08:21 |
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. ;) |
|
|
msg141768 - (view) |
Author: Hynek Schlawack (hynek) *  |
Date: 2011-08-08 10:52 |
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. |
|
|
msg141935 - (view) |
Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) *  |
Date: 2011-08-12 02:09 |
+def starmapstar(args): + return list(itertools.starmap(args[0], args[1])) Is your new function restricted to 2 arguments? |
|
|
msg141941 - (view) |
Author: Hynek Schlawack (hynek) *  |
Date: 2011-08-12 07:34 |
No, that's just a helper function like the `mapstar` directly above. args[1] is the iterable with tuples that get unpacked as arguments. |
|
|
msg149914 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2011-12-20 14:58 |
This looks like a reasonable request to me, and the patch looks generally ok as well. |
|
|
msg149916 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2011-12-20 15:03 |
One nit: the patch needs "versionadded" tags for the two new functions. |
|
|
msg149921 - (view) |
Author: Hynek Schlawack (hynek) *  |
Date: 2011-12-20 17:51 |
Thanks for the feedback Antoine! I updated the patch to latest default tip and added the requested tags to the docs. |
|
|
msg149922 - (view) |
Author: Charles-François Natali (neologix) *  |
Date: 2011-12-20 18:18 |
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. |
|
|
msg149923 - (view) |
Author: Hynek Schlawack (hynek) *  |
Date: 2011-12-20 18:56 |
You're right. I've updated the docs accordingly, thanks! |
|
|
msg149975 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2011-12-21 10:04 |
New changeset b07b1e58582d by Antoine Pitrou in branch 'default': Issue #12708: Add starmap() and starmap_async() methods (similar to itertools.starmap()) to multiprocessing.Pool. http://hg.python.org/cpython/rev/b07b1e58582d |
|
|
msg149976 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2011-12-21 10:05 |
Patch committed. Thanks for your contribution! |
|
|