Iterators & Generators
Iterators
The iterator protocol — understanding __iter__ and __next__ methods, how for loops work internally, and building custom iterable sequences.
Iterables
Understanding iterables vs iterators — objects that can produce iterators, the iter() function, and building custom iterable collections.
Generators
Generator functions using yield — lazy evaluation, memory efficiency, sending values into generators, and generator lifecycle management.
Generator Expressions
Memory-efficient lazy evaluation using generator expressions — the parenthesized form of list comprehensions that produces values on demand.
itertools Module
The itertools standard library — efficient iteration tools including infinite iterators, combinatoric functions, grouping, and chaining utilities.
yield from
Delegating to sub-generators with yield from — simplifying nested iteration, bidirectional communication, and building recursive generators.
Infinite Iterators
Creating and managing infinite sequences — generators and itertools functions that produce values forever, with strategies for safe consumption.