What are you yield from?
summary
Argues that switching list-heavy code to generators cuts memory and avoids repeated passes, with concrete fixes for Django REST Framework serializers (yielding fields instead of building and trimming lists) and a real one-line yield from refactor for admin read-only fields. Shows benchmarks: generators win around ~100 items, sometimes up to 60% faster, but can be slower past ~10k; inspects libraries (Django ~6% generators, Pandas ~2%, Starlette ~8%, FastAPI heavy on generators) and demos generator pipelines for file parsing and a custom one-line zip that actually works. Repository contains all examples.
AI-written summary · about
chapters (10)
- 0:00Introduction and speaker background
- 2:18Problem with inefficient data handling
- 5:37Generators and their advantages
- 9:37Practical generator examples
- 13:09Generator expressions and yield from
- 16:31Custom ZIP implementation and PEP 618
- 19:02Generator pipelines and architecture
- 20:33Why use generators in regular life
- 23:05Loop statistics in popular libraries
- 26:19Q&A and conclusion








