Python Advanced: Generators, Coroutines, and Async/Await
Published by Pearson
This fast-paced class is aimed at Python programmers looking to improve their knowledge of the language with a focus on improving their ability to use Python's advanced features to build robust software systems.
This training is a deep dive into generators and coroutines in Python. This training approaches these features from a functional perspective but doesn't shy away from going deep into detail to give students a practical and comprehensive understanding of the topics.
What you’ll learn and how you can apply it
- How Python generators work and what problems they can be used to solve.
- How Python coroutines work and what problems they can be used to solve.
This live event is for you because...
- You want to understand how advanced features of Python solve real problems
- You want to improve your understanding of Python at a fundamental level
- You want to be able to write powerful systems and libraries using these features
Prerequisites
- Understanding of basic Python syntax
- Understanding of basic Python OO programming
Course Set-Up:
- Python 3.8 or higher
- Code files will be provided to you during the class.
Resources:
Schedule
The time frames are only estimates and may vary according to how the class is progressing.
Generators (120 minutes)
- the data model: iter and next (15 minutes)
- How does Python implement generators at the language level?
- How does this fit into the idea of Python being a protocol-driven
- language?
- What is the iter/next protocol?
- the generator formulation (15 minutes)
- How does the
def/yieldformulation of a generator implement the iter, next protocols? - comprehensions and generator expressions (15 minutes)
- What is comprehension syntax?
- What is a list, set, dict comprehension?
- What is a generator expression?
- generators as a mechanism for laziness (10 minutes)
- What are generators useful for? Laziness-vs-eagerness.
- generators as a mechanism for sequencing (10 minutes)
- What are generators useful for? Enforced sequencing of operations.
- pipeline-style programming with generators (10 minutes)
- What are generators useful for? Pipeline-style dataflow programming.
- itertools (10 minutes)
- How does the itertools module help us work with iterators and generators?
- the C API (5 minutes, if time permits)
- What does the C-API for generators look like?
Coroutines (60 minutes)
- the data model (15 minutes)
- Extending the data model with send and throw.
- "pumping" or "priming" (5 minutes)
- Why coroutines need to be “pumped” or “primed”?
- simplifying APIs with coroutines (15 minutes)
- What are coroutines for? Simpler APIs using coroutines as functions with state.
- coroutines for sequencing (10 minutes)
- What are coroutines useful for? Sequencing?
- building a custom async loop (15 minutes)
- Building an async scheduler using coroutines.
Your Instructor
James Powell
James Powell is a world-renowned expert in data science and open source scientific computing. His subject mastery and guidance are sought after by global organizations for consulting, coaching, and staff training. He is one of the most prolific speakers in the community, and he shares new content each week on his YouTube page, LinkedIn, and Discord.
In addition to O’Reilly Online Learning, James and his team at Don't Use This Code provide Python training and consulting services. He would love to talk to you about how your team uses open source tools for AI/ML - e-mail him at james@dutc.io.
James’s courses are dense and fast-paced. Be sure to stay for the full session and don’t worry if it goes by quickly. You’ll want to re-watch the video later to capture all of the details.