Now, let's turn to the question of performance. Once in a while, our application will need to be constantly monitored and, if needed, scaled and optimized. There are a few ways to speed things up incrementally, for example, by installing the ujson package, which works exactly like built-in json but is more performant (because it is written in C). In that case, FastAPI will automatically switch to using this library instead.
Potentially, more significant improvement in performance is built into FastAPI, Uvicorn, and based on the new features of Python 3.4 and later versions, asynchronous calls. We did spend some time discussing this feature in Chapter 3, Functions. In a nutshell, all of the code we generally write in Python is executed sequentially—once one line is executed, Python will go to the next, and so on. It means that, when...