FastAPI: Modern Python Web Development (Final)КНИГИ » ПРОГРАММИНГ
Название: FastAPI: Modern Python Web Development (Final) Автор: Bill Lubanovic Издательство: O’Reilly Media, Inc. Год: 2024 Страниц: 280 Язык: английский Формат: pdf (true), epub (true) Размер: 24.0 MB, 10.2 MB
FastAPI is a young yet solid framework that takes advantage of newer Python features in a clean design. As its name implies, FastAPI is indeed fast, rivaling similar frameworks in languages such as Golang. With this practical book, developers familiar with Python will learn how FastAPI lets you accomplish more in less time with less code.
Author Bill Lubanovic covers the nuts and bolts of FastAPI development with how-to guides on various topics such as forms, database access, graphics, maps, and more that will take you beyond the basics. This book also includes how-to guides that will get you up to speed on RESTful APIs, data validation, authorization, and performance. With its similarities to frameworks like Flask and Django, you'll find it easy to get started with FastAPI.
The term concurrency doesn’t mean full parallelism. Multiple processing isn’t occurring in the same nanosecond, in a single CPU. Instead, concurrency mostly avoids busy waiting (idling the CPU until a response is delivered). CPUs are zippy, but networks and disks are thousands to millions of times slower. So, whenever we talk to a network or disk, we don’t want to just sit there with a blank stare until it responds.
Normal Python execution is synchronous: one thing at a time, in the order specified by the code. Sometimes we want to be asynchronous: do a little of one thing, then a little of another thing, back to the first thing, and so on. If all our code uses the CPU to calculate things (CPU bound), there’s really no spare time to be asynchronous. But if we perform something that makes the CPU wait for an external thing to complete (I/O bound), we can be asynchronous.
Asynchronous systems provide an event loop: requests for slow operations are sent and noted, but we don’t hold up the CPU waiting for their responses. Instead, some immediate processing is done on each pass through the loop, and any responses that came in during that time are handled in the next pass. The effects can be dramatic. Later in this book, you’ll see how FastAPI’s support of asynchronous processing makes it much faster than typical web frameworks.
Asynchronous processing isn’t magic. You still have to:
Through the course of this book, you will: • Learn how to build web applications with FastAPI • Understand the differences between FastAPI, Starlette, and pydantic • Learn two features that set FastAPI apart: asynchronous functions and data type checking and validation • Examine new features of Python 3.8+, especially type annotations • Understand the differences between sync and async Python • Learn how to connect with external APIs and services
Скачать FastAPI: Modern Python Web Development (Final)