~/talk

What are you yield from?

Talkat PyCon Italia 2023 · 2023-05-25..05-28· [python, software-architecture]
slides:none on file

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

  1. 0:00Introduction and speaker background
  2. 2:18Problem with inefficient data handling
  3. 5:37Generators and their advantages
  4. 9:37Practical generator examples
  5. 13:09Generator expressions and yield from
  6. 16:31Custom ZIP implementation and PEP 618
  7. 19:02Generator pipelines and architecture
  8. 20:33Why use generators in regular life
  9. 23:05Loop statistics in popular libraries
  10. 26:19Q&A and conclusion
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.