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.

Author techtonik
Recipients rhettinger, techtonik
Date 2013-04-28.16:13:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1367165590.04.0.46648726654.issue17862@psf.upfronthosting.co.za>
In-reply-to
Content
The history:
2007 - http://bugs.python.org/issue1502
2009 - http://bugs.python.org/issue6021

I'd like to resurrect this proposal again, but name it:
  itertools.chunks(iterable, size, fill=None)

Two reasons.
1. practicality  - top itertools request on StackOverflow
http://stackoverflow.com/search?tab=votes&q=%5bpython%5d%20%2bitertools

2. performance
the time should be a constant for a fixed-length iterable regardless of a size of chunk, but in fact the time is proportional to the size of chunk

{{{
import timeit

print timeit.timeit(
  'grouper(30000, "x"*400000)', setup='from __main__ import grouper', number=1000
)
print timeit.timeit(
  'grouper(300000, "x"*400000)', setup='from __main__ import grouper', number=1000
)
}}}

1.52581005407
14.6219704599


Addressing odd length user stories from msg87745:
1. no exceptions - odd end is an easy check if you need it
2. fill-in value - provided
3. truncation - just don't set fill-in value
3.1. if you really need fill-in as None, then an itertools.TRUNCATE value can be used as a truncation parameter
4. partially filled-in tuple - not sure what that means

Raymond, your opinion is critical here. =)
History
Date User Action Args
2013-04-28 16:13:10techtoniksetrecipients: + techtonik, rhettinger
2013-04-28 16:13:10techtoniksetmessageid: <1367165590.04.0.46648726654.issue17862@psf.upfronthosting.co.za>
2013-04-28 16:13:10techtoniklinkissue17862 messages
2013-04-28 16:13:09techtonikcreate