[Patches] [ python-Patches-756253 ] itertools roundrobin()
SourceForge.net
noreply at sourceforge.net
Fri Apr 30 18:58:02 EDT 2004
Patches item #756253, was opened at 2003-06-17 16:35
Message generated for change (Comment added) made by rhettinger
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=756253&group_id=5470
Category: Modules
Group: Python 2.4
Status: Closed
Resolution: Rejected
Priority: 5
Submitted By: Jack Diederich (jackdied)
Assigned to: Raymond Hettinger (rhettinger)
Summary: itertools roundrobin()
Initial Comment:
a patch to add the roundrobin() and window() objects to
the itertools module. Hettinger has already seen the
implementation of roundrobin, but not window.
test_itertools.py in a seperate patch
----------------------------------------------------------------------
>Comment By: Raymond Hettinger (rhettinger)
Date: 2004-04-30 17:58
Message:
Logged In: YES
user_id=80475
For the record, here a simple and efficient roundrobin task
server based on collections.deque:
def roundrobin(*iterables):
pending = deque(iter(i).next for i in iterables)
gettask, scheduletask = pending.popleft, pending.append
while pending:
task = gettask()
try:
yield task()
except StopIteration:
continue
scheduletask(task)
for value in roundrobin('abc', 'd', 'efgh'):
print value
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2004-04-26 18:42
Message:
Logged In: YES
user_id=80475
Decided not to include this in Py2.4.
The tool is not sufficiently general. It has only one use
case and arguably that case is better served with
collections.deque().
The point in favor of the tool is that it cannot be
constructed from other itertools.
----------------------------------------------------------------------
Comment By: Jack Diederich (jackdied)
Date: 2003-09-02 19:25
Message:
Logged In: YES
user_id=591932
The newest triplet of module/test/documentation incorporate
your change suggestions. That includes the removal of the
window() stuff, so these only contain roundrobin() related
patches.
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2003-08-27 00:13
Message:
Logged In: YES
user_id=80475
Jack, are you still working on this one?
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2003-07-01 00:12
Message:
Logged In: YES
user_id=80475
Great. I look forward to it.
----------------------------------------------------------------------
Comment By: Jack Diederich (jackdied)
Date: 2003-06-27 13:33
Message:
Logged In: YES
user_id=591932
pushed to 2.4
I'll put up patches that incorporate rhettinger's feedback
soon, and definitely in time for the 2.4 branch.
----------------------------------------------------------------------
Comment By: Jack Diederich (jackdied)
Date: 2003-06-27 13:27
Message:
Logged In: YES
user_id=591932
added Lib/test/test_itertools.py patch here, deleted old
item that just had that patch in it
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2003-06-18 15:11
Message:
Logged In: YES
user_id=80475
*Please post the tests to this patch and close the other patch.
*Add a documentation patch to this patch
*Let's drop the addition of window(). The C code for it is less
than beautiful and offers only a minimal performance gain
over the pure python equivalent. I've added the pure python
version to the docs so folks can cut and paste it if they need
it. Sorry for the wild goose chase (I had expected the C
version to be much cleaner and faster and that the python
verions would've been harder -- actual code was needed for
me to see it).
* In roundrobin_next(), replace the % operator with:
if (lz->iternum==lz->itersize) lz-iternum=0;
* In roundrobin_next(), remove the extra blank line
following "long listsize;"
* Fixup the indentation, currently it is a mix of spaces and
tabs. It should be just pure tabs.
* Replace the variable name 'lz' with 'rr'. I should have
changed that in other places too but for new code it
should be fixed.
* 'unti' is mispelled in the docstring.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=756253&group_id=5470
More information about the Patches
mailing list