Generators

Generators are lazy-evaluating data structures. The values are generated on demand which allows processing iterables without loading all of the iterable into memory at once. This makes chaining several generators very efficient.

Warning

Generators have one disadvantage over data structures like i.e. lists or tuples: They can be only processed once. Once the generator is exhausted the generator cannot be processed again.

Generators can be created in very different contexts, in this section these are grouped into three categories: processing an iterable, processing a value and from a function.

Processing an iterable

Processing several iterables

Note

These functions are implemented as methods for ManyIterables.

Processing a value

From a function