Lazy Looping: The Next Iteration
summary
Shows that iterators are lazy single‑use iterables and that generator functions and generator expressions are the practical ways to build them, with concrete examples: a denumerate generator replacing a list, an around and strip_newlines utilities that implement before/after line context, and an expense summation using csv.reader + generator expression fed to sum. Claims measurable memory efficiency and cleaner, more readable loops; provides working code and points to more_itertools/boltons helpers.
AI-written summary · about
chapters (17)
- 0:00Intro
- 0:32Problem
- 0:52Iterables
- 1:23Iterators
- 2:07File Iterators
- 3:16Benefits
- 4:17Creating Iterators
- 6:30Looping Generators
- 9:00Generator Functions
- 10:40Looping
- 11:43Wrapping Iterators
- 14:49Revisiting Problem Code
- 15:24Aspirational Programming
- 16:55Lazy Looping Helpers
- 17:59Windowed
- 18:26Generator
- 20:54Recap
related talks
02mTutorial Sneak Peek: "Lazy Looping in Practice..."
28mLoop better: a deeper look at iteration in Python
44mIterables and Iterators: Going Loopy With Python
29mPythonic iterators and generators
03mReimplement `itertools` for fun & profit
33mComprehensible Comprehensions
49mGenerators Will Free Your Mind
27mWhen to refactor your code into generators and how
