Iterators and Generators

The iterator protocol, custom iterators, yield, generator expressions and lazy evaluation.

3 notes

Notes

Python

Iterables and Iterators

An iterable can produce an iterator; an iterator produces one value at a time and remembers where it is. Every for loop in Python is built on those tw...

Read more
Python

Generators and yield

A generator function produces values one at a time and pauses between them, keeping all its local state. It is the easiest way to write an iterator an...

Read more