fastapi-deferred-init


Namefastapi-deferred-init JSON
Version 0.2.2.post1 PyPI version JSON
download
home_page
SummaryFaster FastAPI start-up time for Projects with many nested routers
upload_time2023-11-05 21:40:05
maintainer
docs_urlNone
author
requires_python>=3.8
licenseMIT
keywords fastapi speed
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # fastapi-deferred-init

![PyPI - Downloads](https://img.shields.io/pypi/dd/fastapi-deferred-init)
[![GitHub license](https://img.shields.io/github/license/jvllmr/fastapi-deferred-init)](https://github.com/jvllmr/fastapi-deferred-init/blob/master/LICENSE)
![Tests](https://github.com/jvllmr/fastapi-deferred-init/actions/workflows/test.yml/badge.svg)

## 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 get used. In short: values in nested routers are calculated although they will never be used.

## The Solution

This library provides a modified APIRoute that defers the calculation of values to the first actual attribute access. A router which uses the route as a default is also provided.

## Caveat

When using the deferred APIRoute on every layer of the app, startup errors are deferred to the first time a route is called. So errors related to route registration might go undetected if the route is not tested at least once.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "fastapi-deferred-init",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "fastapi speed",
    "author": "",
    "author_email": "Jan Vollmer <jan@vllmr.dev>",
    "download_url": "https://files.pythonhosted.org/packages/b8/66/3fa0a43c68d4adc07b3d968bc609371fbb77dc60704b7454725ee43e32dd/fastapi_deferred_init-0.2.2.post1.tar.gz",
    "platform": null,
    "description": "# fastapi-deferred-init\n\n![PyPI - Downloads](https://img.shields.io/pypi/dd/fastapi-deferred-init)\n[![GitHub license](https://img.shields.io/github/license/jvllmr/fastapi-deferred-init)](https://github.com/jvllmr/fastapi-deferred-init/blob/master/LICENSE)\n![Tests](https://github.com/jvllmr/fastapi-deferred-init/actions/workflows/test.yml/badge.svg)\n\n## The Problem\n\nWhen using nested routers in a FastAPI project its start-up time can get long quite fast.\nThat 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 get used. In short: values in nested routers are calculated although they will never be used.\n\n## The Solution\n\nThis library provides a modified APIRoute that defers the calculation of values to the first actual attribute access. A router which uses the route as a default is also provided.\n\n## Caveat\n\nWhen using the deferred APIRoute on every layer of the app, startup errors are deferred to the first time a route is called. So errors related to route registration might go undetected if the route is not tested at least once.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Faster FastAPI start-up time for Projects with many nested routers",
    "version": "0.2.2.post1",
    "project_urls": {
        "Source": "https://github.com/jvllmr/fastapi-deferred-init"
    },
    "split_keywords": [
        "fastapi",
        "speed"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ba9c15903cc07513c197795bb0e3ebe362e5db1c0899cd29435ef62faefe0659",
                "md5": "d43b20af9eafae488e6258a486b8edf2",
                "sha256": "34d28d2844240451c68ab254d6d3079a9f8ad451dfab3b1d50e0c85d0135c5c0"
            },
            "downloads": -1,
            "filename": "fastapi_deferred_init-0.2.2.post1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d43b20af9eafae488e6258a486b8edf2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 5735,
            "upload_time": "2023-11-05T21:40:04",
            "upload_time_iso_8601": "2023-11-05T21:40:04.882310Z",
            "url": "https://files.pythonhosted.org/packages/ba/9c/15903cc07513c197795bb0e3ebe362e5db1c0899cd29435ef62faefe0659/fastapi_deferred_init-0.2.2.post1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b8663fa0a43c68d4adc07b3d968bc609371fbb77dc60704b7454725ee43e32dd",
                "md5": "498c04481f2d0dee7f2dd0db88b1e741",
                "sha256": "2754a4a0704623c091f100d3393f451d919605d502418d68441c6b4595026cc9"
            },
            "downloads": -1,
            "filename": "fastapi_deferred_init-0.2.2.post1.tar.gz",
            "has_sig": false,
            "md5_digest": "498c04481f2d0dee7f2dd0db88b1e741",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 7096,
            "upload_time": "2023-11-05T21:40:05",
            "upload_time_iso_8601": "2023-11-05T21:40:05.928587Z",
            "url": "https://files.pythonhosted.org/packages/b8/66/3fa0a43c68d4adc07b3d968bc609371fbb77dc60704b7454725ee43e32dd/fastapi_deferred_init-0.2.2.post1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-05 21:40:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jvllmr",
    "github_project": "fastapi-deferred-init",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "fastapi-deferred-init"
}
        
Elapsed time: 0.14787s