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...
The iterator protocol, custom iterators, yield, generator expressions and lazy evaluation.
3 notes
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...
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...
Lazy means computing a value only when it is asked for. Python uses it throughout, and using it deliberately is what makes a program handle data large...