Skip to main content

PyFerrum

PyPI version Python versions License: MIT CI

A Python web framework with a Rust HTTP runtime. Define routes and application behavior in Python; pyferrum uses Tokio and Hyper for its server, router, and selected request/response fast paths.

Version 1.1.0 adds build-before-run Rust routing support. pyferrum is not an ASGI/WSGI server and is not a drop-in replacement for FastAPI, Flask, or Django. See the comparison and current limitations below before choosing it.

Install

requires rust and cargo stable versions to build source or to build rust routes. install and verify with following commands.

sudo apt update && sudo apt install -y build-essential curl
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
rustc --version
cargo --version

pyferrum supports CPython 3.10 and newer(3.15). PyPy is not a supported runtime.

Releases provide prebuilt wheels for Linux and Windows, but not macOS. On macOS, pip builds the extension from source, so install Rust with Cargo and the Xcode Command Line Tools first (xcode-select --install).

python -m pip install pyferrum

Quick start

Save this as app.py:

from pyferrum import Ferrum, JsonResponse, Request

app = Ferrum()


@app.get("/")
async def index(request: Request):
    return {"hello": "world"}


@app.get("/users/{user_id}")
def get_user(request: Request):
    return {"id": int(request.path_params["user_id"])}


@app.post("/echo")
async def echo(request: Request):
    return JsonResponse({"echoed": request.json()})


if __name__ == "__main__":
    app.run(host="127.0.0.1", port=8080)

Run the app and make a request:

python app.py
curl http://127.0.0.1:8080/
curl -X POST http://127.0.0.1:8080/echo \
  -H 'Content-Type: application/json' \
  -d '{"message":"hello"}'

The pyferrum CLI can run an importable app and optionally watch project Python, Rust, and TOML files:

pyferrum run --dev --build --verify --debug --host 127.0.0.1 --port 8080

By default, pyferrum run imports app:app from app.py. Pass a different module:object value when your application uses another entry point. run never builds or verifies automatically: it uses the custom extension if one has already been built, otherwise the original core. Use pyferrum verify to check Python syntax and Rust route configuration without compiling, and pyferrum build to compile custom routes. pyferrum run --build builds and then starts the app; pyferrum run --core always uses the original core extension. --build and --core cannot be combined. In development mode, --build and --verify opt in to those steps at startup and after changes.

Build Rust routes into the Python extension

Define Rust handlers and route entries with export_routes!, then point rust.native.manifest in your project's config.toml at that Cargo package:

[rust.native]
manifest = "native/Cargo.toml"

[[py.routes]]
method = "GET"
path = "/from-table"
handler = "example"

[[py.routes]] entries are for Python handlers; Rust routes remain defined in Rust source with export_routes!.

With pyferrum installed in the same Python environment that will run the app, build the routes into its Python extension:

python -m pyferrum.cli build
pyferrum run

This atomically replaces the installed _pyferrum extension in the active Python environment; the build does not produce a wheel and does not require a virtual environment. Rust routes are registered automatically when the app creates a Ferrum instance. The build requires Rust/Cargo and pyferrum installed in the active Python environment. The SDK used to compile route crates is bundled with pyferrum; the full ferrum-core source checkout is not needed. It is installed as _pyferrum_sdk/ inside the active pyferrum Python package (normally site-packages/pyferrum/_pyferrum_sdk) and pyferrum build resolves that absolute path automatically. Application Cargo.toml files should use a normal pyferrum-sdk dependency (or omit it when the CLI injects SDK types); the build command dynamically rewrites it to the SDK in the active installation. Native route code runs in process with the server's privileges and must be trusted. pyferrum run uses that extension until rebuilt or run with --core.

--debug enables detailed server logging by setting RUST_LOG=debug; it does not return Python tracebacks to clients. Otherwise, RUST_LOG controls runtime log levels. The application details are printed on startup; the listening banner is an info-level log. Access logging is enabled by --debug or app.run(request_logging=True) and records the response status, method, path (without query string), and request ID. Levels are INFO for 1xx/2xx, DEBUG for 3xx, WARN for 4xx, and ERROR for 5xx; nonstandard 6xx-9xx statuses are WARN. RUST_LOG filters these levels, so 3xx logs require debug logging. For streaming responses, the logged status is the initial response status, not the outcome of transmitting the entire body. See pyferrum run --help for the supported options.

What is included

  • Tokio/Hyper HTTP server and a matchit router with path parameters and 404/405 handling.
  • Synchronous and asynchronous Python handlers. Async handlers share one process-level asyncio event loop; Python handler concurrency is bounded.
  • Rust JSON parsing/serialization for supported Python containers, plus Request, Response, and helpers for JSON, text, HTML, XML, CSV, file downloads, redirects, and server-sent events.
  • Async Python response streaming from bytes/text chunks. Request bodies are buffered, with a 10 MiB engine default.
  • Request/body/connection/shutdown timeouts, header count and size limits, request IDs, configurable security headers, optional fixed-window per-client-IP rate limiting, CORS origin/method/header controls, and an in-flight request cap.
  • Optional PEM-based TLS, trusted-proxy forwarding, gzip for eligible buffered responses, and a small Prometheus-format /metrics endpoint.
  • TOML route tables for explicitly supplied Python handlers.
  • Rust routes defined with export_routes!, plus static-file and redirect helpers.
  • Optional Rust native route plugins. Plugins run synchronously in-process, are not sandboxed, and must be trusted.
  • A pyferrum command-line runner and optional worker subprocesses on platforms supporting SO_REUSEPORT.

The defaults include a 100-handler Python concurrency limit, a 1,000-request process limit, enabled security headers and gzip, and disabled rate limiting. See ARCHITECTURE.md for request flow, options, and limits. For the complete Python API, route/response helpers, and server option reference, see API.md.

Comparison

These projects solve related but different problems. This table compares their documented roles, not benchmark results.

Project Main role Application interface Important distinction
pyferrum Rust HTTP runtime with Python route handlers pyferrum decorators and request/response types Does not currently host ASGI/WSGI apps or provide built-in OpenAPI, request-model validation, or a broad extension ecosystem.
FastAPI Python ASGI web framework ASGI, type hints, dependency injection Includes an established validation and OpenAPI workflow and integrates with ASGI servers such as Uvicorn.
Flask Python WSGI web framework WSGI and Flask extensions Offers a mature, flexible Python framework and extension ecosystem.
Uvicorn / Hypercorn ASGI servers ASGI application objects These are servers rather than direct equivalents to a routing framework; they commonly run FastAPI or Starlette apps.

Choose pyferrum when you want its Rust-backed server and direct Python decorator API, and its narrower ecosystem meets your needs. Choose FastAPI, Flask, or Django when their compatibility, validation, middleware, or ecosystem is a requirement. There are no performance numbers or universal speedup claims in this README.

Current limitations

The 1.1.0 API release does not imply feature parity with larger frameworks. In particular, pyferrum does not currently include:

  • ASGI/WSGI hosting or compatibility adapters.
  • Built-in authentication/authorization or CSRF middleware, or an ORM.
  • OpenAPI generation or built-in schema-based request validation.
  • WebSockets or streaming request-body APIs.
  • HTTP/3; explicit HTTP/2 TLS ALPN behavior and integration coverage remain roadmap work.

Rate limiting is disabled unless configured. TLS is optional and uses certificate/key files supplied by the application; there is no automatic certificate provisioning or client-certificate authentication. Security headers and resource limits are safeguards, not substitutes for application authentication, authorization, input validation, or deployment controls. Native plugins execute with the server process's privileges.

Examples and documentation

License

pyferrum is open-source software licensed under the MIT License.

Contributing and security

Contributions are welcome; start with CONTRIBUTING.md. Please report vulnerabilities privately as described in SECURITY.md, not in a public issue.

Publishing

Maintainers publish releases through the GitHub Actions workflow using PyPI Trusted Publishing. The workflow and required publisher configuration are in .github/workflows/release.yml.

Metadata

Release files for pyferrum 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyferrum 1.1.0
File Size Uploaded Provenance Actions
pyferrum-1.1.0.tar.gz 97.2 kB With provenance Details for pyferrum-1.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pyferrum 1.1.0
File Actions
pyferrum-1.1.0-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details for pyferrum-1.1.0-cp310-abi3-win_arm64.whl
pyferrum-1.1.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for pyferrum-1.1.0-cp310-abi3-win_amd64.whl
pyferrum-1.1.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for pyferrum-1.1.0-cp310-abi3-musllinux_1_2_x86_64.whl
pyferrum-1.1.0-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details for pyferrum-1.1.0-cp310-abi3-manylinux_2_28_x86_64.whl
pyferrum-1.1.0-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details for pyferrum-1.1.0-cp310-abi3-manylinux_2_28_aarch64.whl

Total release size: 11.8 MB

Release files / pyferrum-1.1.0.tar.gz

Download URL pyferrum-1.1.0.tar.gz
Size 97.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9da894756e1af271dd753784c00d872ed30043e2d36cb16afc4fa7772d9e799a
BLAKE2b-256 checksum
How to use checksums
cf1f63af8230a5e224dc4387f8299bdf25a9f62bebce122cd915f5e7fa05d210
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / pyferrum-1.1.0-cp310-abi3-win_arm64.whl

Download URL pyferrum-1.1.0-cp310-abi3-win_arm64.whl
Size 2.1 MB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
a8646df9b1ad9da3d37bdac2237826e6c73a0f9935caf41a757953ce86c17068
BLAKE2b-256 checksum
How to use checksums
7a4e0b28d784197eddf79337060de7518e2cfe50666d9a78f0829cb39c9ee58a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / pyferrum-1.1.0-cp310-abi3-win_amd64.whl

Download URL pyferrum-1.1.0-cp310-abi3-win_amd64.whl
Size 2.1 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
e56015e93e6661285186b3e7dae296f2146ed59188a6803c01929901f691ca1d
BLAKE2b-256 checksum
How to use checksums
7f049d7a8d1d0f97eac56f7d40b6bfd47bbd99c3c6fb933e406faacf3ce8acfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / pyferrum-1.1.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL pyferrum-1.1.0-cp310-abi3-musllinux_1_2_x86_64.whl
Size 2.6 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
96a19e3d80d8966cb4ef5fcd6eeca7945ded503cba9d1763b7274e0d03be17b7
BLAKE2b-256 checksum
How to use checksums
c82581888e9a27ef0bd2ceb7f0f5009887406d81230eb21b5ce8655f5b966c32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / pyferrum-1.1.0-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL pyferrum-1.1.0-cp310-abi3-manylinux_2_28_x86_64.whl
Size 2.6 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
82ae74ef2817e05ed376acfe375a1f2ffbda8c13615ef39cf212bfc76ff96fd1
BLAKE2b-256 checksum
How to use checksums
d82c2094f89d967f3cc328298b03bb566c1c677832ab6216f32db10970b2ca32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / pyferrum-1.1.0-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL pyferrum-1.1.0-cp310-abi3-manylinux_2_28_aarch64.whl
Size 2.4 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
2d6ad2175418bf5f58a31a04efb1b63cad3d49ef0fff52a2f6f3b49e1b2f6538
BLAKE2b-256 checksum
How to use checksums
d42a6be44a1490f0e4f23107d766ed3ef289bd3f1ca0915b4c6d10e3ade95feb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Security for pyferrum 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for pyferrum-1.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

6 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page