Skip to main content Brad's PyNotes

Posts on Generators

  1. PEP 525 - Asynchronous Generators

    TL;DR

    PEP 525 introduced asynchronous generators to Python 3.6, enabling functions that combine async def with yield statements. This feature simplifies creating asynchronous data sources by replacing verbose iterator classes with concise generator syntax, delivering approximately 2.3x better performance.

  2. PEP 380 Yield From

    TL;DR

    PEP 380 introduced yield from syntax for delegating to subgenerators, simplifying generator composition and enabling generators to return values.

    Interesting!

    yield from was the foundation that made async/await possible - it established the delegation pattern that coroutines needed!