One of his concluding points was really helpful for me. I found it hard to pay a lot of attention to the evolution of PEP 342, which added coroutine support for generators. I found it confusing that yield / generators were being extended to handle different use cases. David clarifies it in a helpful way:
There are three main uses of yield
Do NOT write generator functions that try to do more than one of these at once
- Iteration (a producer of data)
- Receiving messages (a consumer)
- A trap (cooperative multitasking)
No comments:
Post a Comment