[Python-Dev] Adding concat function to itertools (original) (raw)
Brett Cannon brett at python.org
Fri Sep 28 19:07:40 CEST 2007
- Previous message: [Python-Dev] Adding concat function to itertools
- Next message: [Python-Dev] Adding concat function to itertools
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 9/22/07, Bruce Frederiksen <dangyogi at gmail.com> wrote:
I've added a new function to itertools called 'concat'. This function is much like chain, but takes all of the iterables as a single argument. Thus concat(someiterables) is logically equivalent to chain(*someiterables); the difference being that chain(*someiterables) results in someiterables being fully expanded before the call to chain, while concat(someiterables) only iterates on someiterables as needed. This makes concat more attractive when someiterables is either expensive to expand or "infinite" in length. Thus, concat(iterable) is like: def concat(iterables): for it in iterables: for element in it: yield element
I've attached an updated itertoolsmodule.c file to this email with concat added to it. This was based on the 2.5.1 source. I ask that this be considered for adoption into standard python. Thanks in advance!
Best thing to do is to put this up on the bug tracker (bugs.python.org) and assign it to Raymond Hettinger as itertools is his baby.
-Brett
- Previous message: [Python-Dev] Adding concat function to itertools
- Next message: [Python-Dev] Adding concat function to itertools
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]