Skip to main content

Faster FastAPI start-up time for Projects with many nested routers

Reason this release was yanked:

Not functioning

Project description

fastapi-deferring-init

WARNING: This is the very first draft of this project and might not work at all. I only published it to test it in bigger projects of mine.

The Problem

When using nested routers in a FastAPI project its start-up time can get long quite fast. That is because every router re-calculates the routes defined by a nested router when including it and the pre-calculated values by the nested router never gets used.

The Solution

This library provides a modified APIRoute that defers the calculation of values to the first actual attribute access. This also applies to the top-level router, which means that the route is only fully initialized when an API Endpoint is accessed the first time. Utilities for quickly monkey-patching an existing FastAPI application are also provided.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_deferred_init-0.1.0.tar.gz (17.1 kB view hashes)

Uploaded Source

Built Distribution

fastapi_deferred_init-0.1.0-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page