New submission from anatoly techtonik: 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. =) ---------- components: Library (Lib) messages: 187995 nosy: rhettinger, techtonik priority: normal severity: normal status: open title: itertools.chunks(iterable, size, fill=None) versions: Python 3.3, Python 3.4, Python 3.5 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17862> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com