Reuven Lerner - Generators, coroutines, and nanoservices
Channel: EuroPython Conference
Date: 2021-10-04

Generators, coroutines, and nanoservices
[EuroPython 2021 - Talk - 2021-07-29 - Optiver]
[Online]

By Reuven Lerner

Generator functions have been a part of Python for many years already, and are a well known technique for creating iterators. But generators have a few lesser-known aspects, including their “send” method and the “yield from” syntax. Many Python developers shy away from using them, unsure of what they would do, or how they would be useful — seeing coroutines as a solution looking for a problem.

In this talk, I’ll tell you why coroutines can be useful, and how thinking about them as in-process “nanoservices” puts us in the right frame of mind to determine when they would and wouldn’t be appropriate. Among the topics we’ll explore are:

Generator function basics
next vs. send
How to build a coroutine
Thinking of coroutines as nanoservices
Sub-coroutines
The need for yield from
Using yield from
Ideas for general usage



License: This video is licensed under the CC BY-NC-SA 4.0 license: https://creativecommons.org/licenses/by-nc-sa/4.0/
Please see our speaker release agreement for details: https://ep2021.europython.eu/events/speaker-release-agreement/