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: Improve itertools.starmap
Type: Stage:
Components: Extension Modules Versions: Python 2.5
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: anthonybaxter, collinwinter, jackdied, quiver, rhettinger
Priority: normal Keywords: patch

Created on 2006-05-31 17:41 by collinwinter, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
better_starmap.patch collinwinter, 2006-06-27 09:22 Improve itertools.startmap(), against r47103
Messages (8)
msg50390 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2006-05-31 17:41
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.
msg50391 - (view) Author: George Yoshida (quiver) (Python committer) Date: 2006-06-01 01:36
Logged In: YES 
user_id=671362


msg50392 - (view) Author: Jack Diederich (jackdied) * (Python committer) Date: 2006-06-09 20:13
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.
msg50393 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2006-06-27 09:22
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.
msg50394 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2006-07-17 01:00
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().
msg50395 - (view) Author: Jack Diederich (jackdied) * (Python committer) Date: 2006-07-18 03:42
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.
msg50396 - (view) Author: Anthony Baxter (anthonybaxter) (Python triager) Date: 2006-07-25 07:20
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.
msg80621 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2009-01-27 05:14
This was fixed in r60013.
History
Date User Action Args
2022-04-11 14:56:17adminsetgithub: 43440
2009-01-27 05:14:58rhettingersetstatus: open -> closed
resolution: out of date
messages: + msg80621
2009-01-27 03:00:49rhettingersetassignee: anthonybaxter -> rhettinger
2006-05-31 17:41:09collinwintercreate