Why chunks is not part of the python standard lib?

Oscar Benjamin oscar.j.benjamin at gmail.com
Thu May 2 09:23:57 EDT 2013


On 2 May 2013 13:55, Chris Angelico <rosuav at gmail.com> wrote:
> On Thu, May 2, 2013 at 10:52 PM, Oscar Benjamin
> <oscar.j.benjamin at gmail.com> wrote:
>> They are all easy to write as generator functions but to me the point
>> of itertools is that you can do things more efficiently than a
>> generator function. Otherwise code that uses a combination of
>> itertools primitives is usually harder to understand than an
>> equivalent generator function so I'd probably avoid using itertools.
>
> Aren't most of the itertools primitives written in Python anyway? If
> your code is harder to understand, just write the generator function!

The documentation describes them by showing equivalent generator
functions and there may be a pure Python version of the module but if
you look here then you can see which are builtin for CPython:

http://hg.python.org/cpython/file/c3656dca65e7/Modules/itertoolsmodule.c#l4070

The list covers all of the documented itertools functions (actually I
now realise that they're mostly types not functions).


Oscar



More information about the Python-list mailing list