Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

Generators, Coroutines, and Nanoservices

EuroPython Conference via YouTube

Overview

Explore the advanced features of Python generators, coroutines, and nanoservices in this EuroPython 2021 conference talk. Delve into the lesser-known aspects of generators, including the "send" method and "yield from" syntax. Learn how to conceptualize coroutines as in-process nanoservices and determine their appropriate use cases. Discover generator function basics, the differences between next and send, coroutine construction techniques, and the implementation of sub-coroutines. Gain insights into practical applications of these concepts through examples such as MD5 hashing and weather data processing. Understand the relationship between coroutines and asyncio, and develop criteria for deciding when to incorporate coroutines in your Python projects.

Syllabus

Intro
The dumbest function in the world
Bytecode from our function
What about this function?
What's the difference?
Bytecodes
What's a generator?
How does a "for" loop work
What about with our generator?
Doing it manually
"next" and generators
fib
Generator example 2: read_n
next_vowel
So, when do we use generators?
"yield" as an expression
The "send" method
Walrus yield
How can I use coroutines?
Coroutine as "nanoservices"
Example: MD5
Coroutine example 1: MD5
Coroutine example 2: Weather
Coroutine example 2.1: Weather
Coroutine example 3
Ending early
Revisiting the weather
Megaservices
Refactoring our generator
"yield from" to the rescue!
What about asyncio?
Should you use coroutines?

Taught by

EuroPython Conference

Reviews

Start your review of Generators, Coroutines, and Nanoservices

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.