| Flask has been around much longer than FastAPI and, as a result, is a much more mature framework. Some examples: - There's a memory leak with a particular combination of packages FastAPI [0] - Before Pydantic v2, you would validate your data on input (when it's stored in the db) and then every single time on retrieval. There is no way to skip validation, for example, when you are generating a response on data that was already validated when it was persisted to the db. [1] - FastAPI has documentation only in the form of tutorials. There is no API documentation and if something is not clear looking through the source code is the only option - You need ORJSON for maximum serialisation performance (perhaps this has changed with Pydantic v2) [2] - Using FastAPI with uvicorn doesn't respect log format settings [3] I don't mean to imply that FastAPI is a bad framework. The Flask ecosystem has had over a decade to mature. FastAPI and the ecosystem will get there but it _needs_ time. - [0] https://github.com/tiangolo/fastapi/discussions/9082 - [1] https://github.com/pydantic/pydantic/issues/1212 - [2] https://fastapi.tiangolo.com/advanced/custom-response/#use-o... - [3] https://github.com/encode/uvicorn/issues/527 |
The common orjson trick no longer works in v2 and will throw warnings, but it appears it's no longer necessary since the JSON formatting leverages the native seralizer which happens in Rust-land.