FastAPI 0.140.2 optimizes dependencies, adds memory benchmarking
New FastAPI release cuts memory by dropping flat dependency trees
FastAPI, the high-performance Python web framework with over 101k GitHub stars, has released version 0.140.2. The update, pushed by lead developer tiangolo on July 27, brings two key changes under the hood. The primary refactor stops retaining flat dependency trees during request handling. Previously, FastAPI maintained flattened representations of dependencies for each request, which consumed memory unnecessarily. By no longer retaining these trees, the framework reduces memory overhead, especially in applications with complex dependency graphs. This optimization directly benefits developers running high-traffic APIs or resource-constrained environments.
Alongside the refactor, the release adds a new internal memory benchmark (PR #16064). This benchmark will help the core team track memory usage trends across future versions, making it easier to catch regressions early. While no other features or bug fixes are included, this focused release signals a commitment to efficiency. FastAPI continues to be a go-to choice for building modern APIs with Python, and version 0.140.2 is a quiet but meaningful step toward leaner performance. Developers can upgrade via pip install --upgrade fastapi and check the GitHub release notes for full details.
- Version 0.140.2 released July 27 by tiangolo with a refactor to stop retaining flat dependency trees (PR #16065)
- New internal memory benchmark added to monitor performance (PR #16064)
- Framework now has 101k stars and 9.7k forks on GitHub, reflecting its popularity
Why It Matters
Reduces memory footprint in FastAPI apps, improving scalability for production Python APIs.