FastAPI 0.140.4 has been released, bringing under‑the‑hood improvements that make dependency resolution leaner. The standout change is a refactor that skips unused dependency repeat bookkeeping, reducing overhead when dependencies are detected as not required for a given request.
- Performance refactor: The core change in PR #16069 by @tiangolo optimizes how FastAPI tracks and resolves dependencies. Previously, the framework performed bookkeeping for dependencies even when they were eventually skipped (e.g., because a sub‑dependency was already resolved or a condition prevented execution). Now, the
resolve_dependentinternal machinery skips that bookkeeping entirely for unused dependencies, lowering per‑request CPU and memory usage. - Backward compatible: This refactor alters no public API—only internal implementation details. Your existing dependency injection code remains 100% compatible without any changes.
- No new features: This release is strictly a performance patch. No new endpoints, parameters, or configuration options were introduced.
For developers building high‑traffic APIs, this optimization can compound into noticeable latency reductions. Every request that involves multiple dependencies (sub‑dependencies, global dependencies, or conditional override paths) now executes less unnecessary work. While the improvement is most measurable in applications with heavily layered dependency graphs, all FastAPI users benefit from a leaner runtime.
The focus on internal efficiency reflects FastAPI’s maturation: the framework is now tuned for production at scale. To upgrade, run:
pip install --upgrade fastapi==0.140.4
Source: https://github.com/fastapi/fastapi/releases/tag/0.140.4