An excellent feature of Python's generators is constant memory usage. Short generators and infinite generators are both the same size, a consequence of not storing any values the generator produces. Once a value is produced, it is thrown away. One can not look into a generator's past or future. This article is about using the limitations of generators to your advantage. |