Главная
Study mode:
on
1
Intro
2
I teach Python!
3
The dumbest function in the world
4
Bytecode from our function
5
Resume?
6
"yield" changes everything
7
Resume is back!
8
The iterator protocol
9
Generators implement this protocol
10
Calling iter() gets an object's iterator
11
"next" advances the generator
12
fib
13
read_n
14
next_vowel
15
So, when do we use generators?
16
Using our generator with "send"
17
How can I use coroutines?
18
Coroutine as "nanoservices"
19
Example: MD5
20
Coroutine example 1: MD5
21
Coroutine example 2: Weather
22
Coroutine example 2.1: Weather
23
When we get to the end of the list...
24
The "throw" method
25
Revisiting the weather
26
Refactoring our generator
27
"yield from" to the rescue!
28
What about asyncio?
29
Should you use coroutines?
30
Questions?
Description:
Explore the advanced features of Python generators, coroutines, and their practical applications in this 26-minute PyCon US talk. Dive 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 discover when they are most appropriate to use. Examine real-world examples, such as implementing MD5 hashing and weather data processing, to understand the power of these Python constructs. Gain insights into refactoring generators, handling exceptions with the "throw" method, and leveraging the "yield from" statement for cleaner code. Conclude with a brief discussion on asyncio and guidelines for effectively incorporating coroutines into your Python projects.

Generators, Coroutines and Nanoservices

PyCon US
Add to list
0:00 / 0:00