[Patches] [ python-Patches-1498370 ] Improve itertools.starmap

SourceForge.net noreply at sourceforge.net
Tue Jul 25 09:20:32 CEST 2006


Patches item #1498370, was opened at 2006-06-01 03:41
Message generated for change (Comment added) made by anthonybaxter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1498370&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Modules
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Collin Winter (collinwinter)
Assigned to: Anthony Baxter (anthonybaxter)
Summary: Improve itertools.starmap

Initial Comment:
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.

----------------------------------------------------------------------

>Comment By: Anthony Baxter (anthonybaxter)
Date: 2006-07-25 17:20

Message:
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.


----------------------------------------------------------------------

Comment By: Jack Diederich (jackdied)
Date: 2006-07-18 13:42

Message:
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.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2006-07-17 11:00

Message:
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().

----------------------------------------------------------------------

Comment By: Collin Winter (collinwinter)
Date: 2006-06-27 19:22

Message:
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.

----------------------------------------------------------------------

Comment By: Jack Diederich (jackdied)
Date: 2006-06-10 06:13

Message:
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.


----------------------------------------------------------------------

Comment By: George Yoshida (quiver)
Date: 2006-06-01 11:36

Message:
Logged In: YES 
user_id=671362




----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1498370&group_id=5470


More information about the Patches mailing list