THE ATHENA LIBRARY
Pythonic Data Handling
Lecture notes · Dr. Hanna Girma lecture notes
Lecture 3
Iterators and generators
Any object implementing __iter__ and __next__ is an iterator. A generator function, marked by yield, builds one automatically and produces values lazily.
Lazy evaluation keeps memory use constant even for very large inputs — an important property when processing datasets that do not fit in memory.
Generator expressions, such as sum(x * x for x in data), combine readability with efficiency.
Fictional educational sample written for the Athena demo · Page 14 of 96.
50%saved