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.
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¶
These functions are implemented as methods for