Generators in Python
In the next section, we will discuss how to convert the blocking server that we currently have to a non-blocking one, while keeping the calculating functionalities. In order to do that, we will first need to look into another concept in Python programming, called generators. Chances are you have already worked with Python generators, but to recap, we will go over the key features of generators in this section.
Generators are functions that return iterators and can be paused and resumed dynamically. Return values from generators are often compared to list objects, because generator iterators are lazy (https://en.wikipedia.org/wiki/Lazy_evaluation) and only produce results when explicitly asked. For this reason, generator ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access