Author techtonik
Recipients rhettinger, techtonik
Date 2013-04-28.16:13:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The history:
2007 -
2009 -

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

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


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. =)
Date User Action Args
2013-04-28 16:13:10techtoniksetrecipients: + techtonik, rhettinger
2013-04-28 16:13:10techtoniksetmessageid: <>
2013-04-28 16:13:10techtoniklinkissue17862 messages
2013-04-28 16:13:09techtonikcreate