Thursday 9 a.m.–12:20 p.m.
Generators: The Final Frontier
- Audience level:
- Python Core (language, stdlib, etc.)
Python generators have long been useful for solving all sorts of problems involving iteration and data flow. However, one of their more powerful uses is in customizing various aspects of program control flow. In this tutorial, we'll look at some more exotic uses of generators such as writing context managers, inlining callback functions, eliminating recursion, implementing actors, and more.
Generators: The Final Frontier ======================== This tutorial explores advanced uses of generators and coroutines for customizing various aspects of program control-flow. The tutorial will involve looking, in detail, at a series of interesting examples which include the following: - Defining new context managers (@contextmanager decorator) - Inlining callback functions (e.g., understanding tricks underlying features such as the inlineCallbacks decorator in Twisted). - Yieldable threads (side-stepping the GIL). - Implementing simple actors (communicating tasks). - Using generators to eliminate recursion (avoiding the interpreter recursion limit). Although the main focus of the tutorial is on generators, attendees will gain a lot of insight into the inner workings and design of the above topics and how they related to advanced libraries and frameworks.
No handouts have been provided yet for this tutorial