Skip to main content

A from-scratch FastAPI-compatible framework with a Rust core.

Project description

superduperfastapi

superduperfastapi is a from-scratch, Rust-powered framework that aims to be a drop-in replacement for FastAPI while moving hot request-path work into Rust.

[!WARNING] This project is in pre-school-alpha. Expect bugs, missing edge cases, incomplete FastAPI parity, rough packaging, and surprising failures. Do not use it for production traffic without your own compatibility and load tests.

[!IMPORTANT] The package is published as superduperfastapi. It also ships local fastapi and starlette compatibility shims so existing from fastapi import FastAPI imports can be tested against this implementation.

[!NOTE] This project was built using Codex's /goal feature. The work has been tracked as explicit performance and compatibility goals with audits and benchmark artifacts along the way.

Installation

Install from PyPI:

uv pip install superduperfastapi

or:

pip install superduperfastapi

The package depends on Pydantic v2. It does not depend on upstream FastAPI at runtime.

Usage

Use the FastAPI-compatible import when testing an existing app:

from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()


class Item(BaseModel):
    name: str
    count: int


@app.post("/items")
def create_item(item: Item):
    return {"name": item.name, "total": item.count + 1}

Run it with the Rust HTTP server:

from superduperfastapi._core import core

core.run(app, "127.0.0.1", 8000)

core.run(...) runs in the foreground and handles Ctrl-C by asking the Rust server to stop accepting new connections, drain active requests, and exit.

For explicit lifecycle control:

server = core.start_server(app, "127.0.0.1", 8000)
try:
    print(f"Serving on http://127.0.0.1:{server.port()}")
    server.wait()
finally:
    server.shutdown()
    server.wait()

Drop-In Imports

Native import:

from superduperfastapi import FastAPI

FastAPI-compatible import:

from fastapi import FastAPI

The long-term goal is for production FastAPI apps to switch package/runtime plumbing with minimal application-code changes. That goal is not complete yet; treat every app migration as a compatibility exercise.

Examples

Runnable examples live in examples/. Each example is a standalone uv run --script file with inline dependencies that install superduperfastapi from PyPI and start a local server:

uv run --script examples/basic.py
uv run --script examples/async_await.py
uv run --script examples/middleware.py
uv run --script examples/html_rendering.py
uv run --script examples/rust_server.py

Example requests:

curl -X POST http://127.0.0.1:8000/items \
  -H "content-type: application/json" \
  -d '{"name":"widget","count":41}'

curl http://127.0.0.1:8004/hello/Ada

Set SUPERDUPERFASTAPI_HOST or SUPERDUPERFASTAPI_PORT to override the default bind address for any example.

What Is Fast Today

SuperDuperFastAPI builds Rust route specs for supported routes and dispatches those routes through the Rust core. Covered fast-path areas include:

  • route matching with a Rust route index/trie
  • path, query, header, and cookie primitive params
  • primitive application/x-www-form-urlencoded form params
  • primitive multipart File() bytes params, UploadFile params, and repeated file lists
  • JSON request bodies through Pydantic-core validators
  • response-model validation and serialization through Pydantic-core
  • direct Rust JSON response construction for plain JSON-compatible returns
  • built-in JSON, HTML, plain text, redirect, streaming, and file response classes
  • sync and async endpoints/dependencies for the covered dependency graph
  • request-scope sync/async generator dependencies with teardown on the native path
  • Security(...) dependencies for API-key, HTTP bearer/basic, OAuth2 password-bearer, and scoped SecurityScopes helpers
  • simple StaticFiles(directory=...) mounts
  • direct Response returns, background tasks, request injection, and app state
  • built-in CORS, GZip, trusted-host, and HTTPS redirect middleware
  • user @app.middleware("http") routes through Rust dispatch
  • custom add_middleware(...) ASGI middleware through the Rust bridge
  • Rust-side 422 response construction for validation errors

The compatibility matrix records whether each covered feature is passed, fallback, unsupported, or broken.

Current Gaps

The target is maximum request-path performance while preserving drop-in FastAPI behavior. Remaining work includes deeper dependency graph optimization, response-model hot-path tuning, eliminating future fallback areas where possible, more upstream FastAPI test coverage, and production packaging hardening.

Benchmarks

Benchmark summaries are written under benchmarks/results/.

benchmark summary
plain JSON benchmarks/results/bombardier_summary.md
CRUD endpoint matrix benchmarks/results/crud_bombardier_summary.md
dependency graph matrix benchmarks/results/dependency_bombardier_summary.md
multipart upload matrix benchmarks/results/multipart_bombardier_summary.md
response model matrix benchmarks/results/response_model_bombardier_summary.md
security dependency matrix benchmarks/results/security_bombardier_summary.md
route count scaling benchmarks/results/route_count_bombardier_summary.md
validation-heavy payloads benchmarks/results/validation_bombardier_summary.md
OpenAPI generation benchmarks/results/openapi_generation_summary.md
JSONable response matrix benchmarks/results/jsonable_bombardier_summary.md
user middleware matrix benchmarks/results/middleware_bombardier_summary.md

Run a benchmark:

.venv/bin/python benchmarks/run_validation_bombardier.py
.venv/bin/python benchmarks/run_dependency_bombardier.py
.venv/bin/python benchmarks/run_openapi_generation.py

Local Development

Local installation and build steps are for contributors working from this repository.

Create or use the local virtualenv, then install the Rust extension:

.venv/bin/python -m pip install maturin
.venv/bin/maturin develop

Package build:

.venv/bin/maturin build --release

In this repository, PYTHONPATH=python makes fastapi resolve to python/fastapi, a compatibility shim that re-exports superduperfastapi. When present locally, the upstream FastAPI checkout in references/fastapi is a behavior and test reference only. Runtime code must not import upstream FastAPI.

Verification

Local unit suite:

PYTHONPATH=python .venv/bin/python -m unittest discover -s tests

Rust core tests:

cargo test --manifest-path rust/superduperfastapi-core/Cargo.toml

Full recursive FastAPI reference subset:

.venv/bin/python scripts/run_reference_subset.py references/fastapi/tests

Current verified reference result: 3117 passed, 14 skipped, 5 xfailed.

Compatibility Audits

.venv/bin/python scripts/audit_fastapi_compatibility.py
.venv/bin/python scripts/audit_middleware_fast_path.py
.venv/bin/python scripts/audit_validation_errors.py
.venv/bin/python scripts/audit_openapi_parity.py
.venv/bin/python scripts/audit_packaging.py
.venv/bin/python scripts/audit_goal_progress.py
.venv/bin/python scripts/classify_fastapi_features.py

These write Markdown and JSON evidence into benchmarks/results/. The feature matrix exits non-zero if any generated row is broken.

Publishing

Publishing is handled by .github/workflows/publish-pypi.yml. It publishes only when a pull request is merged with the release label. The published package name is superduperfastapi, and the version is read from pyproject.toml.

Configure PyPI trusted publishing for the GitHub repository before running the workflow. The workflow runs on GitHub releases and can also be started manually with workflow_dispatch.

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

superduperfastapi-0.1.2.tar.gz (92.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

superduperfastapi-0.1.2-cp312-cp312-win_amd64.whl (748.0 kB view details)

Uploaded CPython 3.12Windows x86-64

superduperfastapi-0.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (943.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

superduperfastapi-0.1.2-cp312-cp312-macosx_11_0_arm64.whl (868.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file superduperfastapi-0.1.2.tar.gz.

File metadata

  • Download URL: superduperfastapi-0.1.2.tar.gz
  • Upload date:
  • Size: 92.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for superduperfastapi-0.1.2.tar.gz
Algorithm Hash digest
SHA256 fd36a185530ae29a4901549758514c585790b3cf299e7bf1d82404df1c6a92cb
MD5 bfa9ecf01a0617ade5842d4447454b3c
BLAKE2b-256 bdf2e9dd9acd7fe6cb5234913a933ff7c6a5ef4e19fdcb5616fa12f6ef74829c

See more details on using hashes here.

Provenance

The following attestation bundles were made for superduperfastapi-0.1.2.tar.gz:

Publisher: publish-pypi.yml on amalshaji/superduperfastapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file superduperfastapi-0.1.2-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for superduperfastapi-0.1.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0cbbc57d0fd2f7cc39ee27d9c6ef92db39fb1a7b5bc838865697c6738168aea0
MD5 8f502505639e1efff541258d2171abaf
BLAKE2b-256 19dc338aad765cde8d9ada52df75bbe2590afdcf94aae58d779e22d389cd0392

See more details on using hashes here.

Provenance

The following attestation bundles were made for superduperfastapi-0.1.2-cp312-cp312-win_amd64.whl:

Publisher: publish-pypi.yml on amalshaji/superduperfastapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file superduperfastapi-0.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for superduperfastapi-0.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c8ca393ee3212d7bc7923c124387871c74967f85f9ea751a3c6a54f371e0ac2a
MD5 eaff0cc38e1dfb483683eb18624751ed
BLAKE2b-256 7b080646e6a56481b7c5587e8dc5cdf11001916c19bb4f0034c522efcaac1d5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for superduperfastapi-0.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-pypi.yml on amalshaji/superduperfastapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file superduperfastapi-0.1.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for superduperfastapi-0.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bfd75ce8c9f3b012d6516a76454d5594c48d657b3708886f2d006fed9c15c8ad
MD5 9095055f17eeb86df92644ddd12fff9a
BLAKE2b-256 4224c4d3ab2ccf32fcbaf9c637997363983e8998a0c2e3c5c4e76bf7c8ec040e

See more details on using hashes here.

Provenance

The following attestation bundles were made for superduperfastapi-0.1.2-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish-pypi.yml on amalshaji/superduperfastapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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