Generators, coroutines, and nanoservices
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.
Reuven Lerner is a full-time Python trainer. In a given year, he teaches courses at companies in the United States, Europe, Israel, India, and China — as well as to people around the world, via his online courses, including Weekly Python Exercise.
Reuven’s most recent book is “Python Workout,” a collection of Python exercises with extensive explanations, published by Manning.
Reuven’s free, weekly "Better developers" newsletter, about Python and software engineering, is read by more than 18,000 developers around the globe.
Reuven has a bachelor’s degree in computer science and engineering from MIT, and a PhD in learning sciences from Northwestern University. He lives in Modi’in, Israel with his wife and three children.