Skip to main content

Ferronit

English · Русский

PyPI Python License GitHub stars

⚠️ Early development — not production-ready. The API and internals are still changing; use at your own risk.

Your legacy Python service is hitting its performance ceiling. Ferronit moves the hot path — routing, request parsing, JSON, gzip, CORS, PostgreSQL — into a Rust core, while your handlers stay plain Python. A migration, not a rewrite.

Documentation: docs/ — quick start, routing, requests, dependency injection, the data layer (rawdb + rawmodel), DDD/DI, the Rust core, benchmarks, ASVS. (Docs are currently written in Russian.)

Installation

pip install ferronit        # installs the Python layer and the native core together

Ferronit is a single package built with maturin as a mixed project. The core (ferronit._core) is compiled with the abi3-py312 feature, so one wheel works on every CPython from 3.12 to 3.15+. Its only runtime dependency is msgspec (fast JSON/validation). Database drivers are extras — ferronit[postgres] (asyncpg), ferronit[mysql], ferronit[sqlite] — and the data layer imports them lazily, when a pool is created.

# app.py
from ferronit import Ferronit

app = Ferronit()

@app.route("/hello/{name}")
async def hello(name: str):
    return {"hello": name}
ferronit dev                          # dev server (uvicorn, reload)
ferronit dev --server granian         # granian (Rust, ~4× faster)
ferronit run --workers 4              # production: granian, uvicorn fallback

Why it is fast

Routing is Rust matchit, effectively O(1). On database reads the framework stays within ~1.3× of BlackSheep (whose benchmark stand reads with raw asyncpg, no row layer) and beats FastAPI/Django by order of magnitude: typed row models + msgspec reply building cost tens of microseconds, not multiples. Methodology — ab (C client) only, granian, 1 worker; full breakdown in docs/benchmarks.md.

Scenario Ferronit BlackSheep FastAPI
GET /ping (dict) 95 119 req/s 88 951 req/s 19 878 req/s
GET /rows?limit=100 5 674 req/s 7 725 req/s 867 req/s
GET /rows?limit=1000 1 179 req/s 1 588 req/s 146 req/s

Data layer

One thin layer over the driver — rawdb + rawmodel: PostgreSQL (asyncpg), MySQL (aiomysql) and SQLite (aiosqlite) behind the same API. Declarative models, a query DSL (select), relations, a Unit of Work — no ORM. SQL is built from an expression tree and compiled per dialect. Details: docs/data/overview.md.

from typing import Annotated
from ferronit import Ferronit
from ferronit.contrib.rawdb import create_pool
from ferronit.contrib.rawmodel import Model, Relation

class OrderItem(Model):
    __table__ = "order_items"
    id: int = 0
    order_id: int = 0
    name: str = ""

class Order(Model):
    __table__ = "orders"
    id: int = 0
    items: Annotated[list[OrderItem], Relation("order_id")] = []   # 1:N, always loaded

app = Ferronit()

@app.route("/orders")
async def orders():
    pool = await create_pool("postgresql://user:pass@localhost/db")  # usually lifespan/DI
    async with pool.uow(readonly=True) as uow:
        rows = await uow.model(Order).list(limit=10)
    return {"orders": rows}   # items nested in JSON, one WHERE fk = ANY($1)

Development

poetry install --all-extras             # environment in .venv + all dependencies
PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 poetry run maturin develop --release   # build the Rust core
./scripts/check.sh                      # lint → types → docstrings → core build → tests
poetry run pytest tests/ -q             # 265 tests

Poetry manages the environment (poetry.toml keeps the venv inside the project), while the wheel carrying the Rust core is built by maturin (see [tool.maturin] in pyproject.toml), so Poetry itself never installs the project.

  • AGENTS.md — guidance for code agents (Claude Code, Codex, Cursor, …).
  • examples/ — minimal, DI, LLM + SSE, RAG, WebSocket; examples/app.py is the DDD example.
  • The package ships py.typed; type stubs for the Rust core live in ferronit/_core.pyi.
  • bench/ — the measurement rig behind every number above; not part of the package.

Release

# the version lives in two files: ferronit/__init__.py and ferronit-rs/Cargo.toml
git tag -a v0.22.0 -m "Ferronit 0.22.0" && git push origin v0.22.0

Pushing a v* tag triggers .github/workflows/release.yml: checks and tests → wheels (Linux glibc/musl, macOS, Windows) and sdist → GitHub Release with the artifacts → publish to PyPI (API token from the PYPI_API_TOKEN repository secret). If the tag version does not match Cargo.toml/__init__.py, the workflow fails before publishing anything.

Docker

docker build -t ferronit:0.22.0 .
docker run --rm -p 8000:8000 ferronit:0.22.0

License

Apache License 2.0 — see LICENSE. Use, modification and distribution are permitted, including commercial use; copyright notices and the patent grant must be preserved.

Metadata

Release files for ferronit 0.22.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 ferronit 0.22.0
File Size Uploaded Provenance Actions
ferronit-0.22.0.tar.gz 111.8 kB Without provenance Details for ferronit-0.22.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for ferronit 0.22.0
File Actions
ferronit-0.22.0-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details for ferronit-0.22.0-cp312-abi3-win_amd64.whl
ferronit-0.22.0-cp312-abi3-musllinux_1_2_x86_64.whl CPython 3.12 abi3 Linux musl 1.2+ x86-64 Details for ferronit-0.22.0-cp312-abi3-musllinux_1_2_x86_64.whl
ferronit-0.22.0-cp312-abi3-manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.28+ x86-64 Details for ferronit-0.22.0-cp312-abi3-manylinux_2_28_x86_64.whl
ferronit-0.22.0-cp312-abi3-manylinux_2_28_aarch64.whl CPython 3.12 abi3 Linux glibc 2.28+ ARM64 Details for ferronit-0.22.0-cp312-abi3-manylinux_2_28_aarch64.whl
ferronit-0.22.0-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details for ferronit-0.22.0-cp312-abi3-macosx_11_0_arm64.whl
ferronit-0.22.0-cp312-abi3-macosx_10_12_x86_64.whl CPython 3.12 abi3 macOS 10.12+ x86-64 Details for ferronit-0.22.0-cp312-abi3-macosx_10_12_x86_64.whl

Total release size: 3.0 MB

Release files / ferronit-0.22.0.tar.gz

Download URL ferronit-0.22.0.tar.gz
Size 111.8 kB
Tags Source
SHA-256 checksum
How to use checksums
00eaefe003f94a3db5dbea7b6039d349c31b75daaa4f0ffce2423a6ce9ed88b5
BLAKE2b-256 checksum
How to use checksums
da02fada5fdce5ec0b8f27754017348eac5238357fea0251a9579528f12d5aef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / ferronit-0.22.0-cp312-abi3-win_amd64.whl

Download URL ferronit-0.22.0-cp312-abi3-win_amd64.whl
Size 389.9 kB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
97586eeee13f0583ab99fd28dd1b01d6d8114f2bfee1e685276118aa0edcc6fb
BLAKE2b-256 checksum
How to use checksums
855215e8be94bee52209c27d304d611b4b2c9608ae844d342b66b3f32f51647a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / ferronit-0.22.0-cp312-abi3-musllinux_1_2_x86_64.whl

Download URL ferronit-0.22.0-cp312-abi3-musllinux_1_2_x86_64.whl
Size 691.3 kB
Tags CPython 3.12 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
c2fdf72e5bfcd49e33505bad1662ff2d643f1a9ddb72adf32f57cd9bcf3158f9
BLAKE2b-256 checksum
How to use checksums
8707d2f02a6f6337554f692f0245e8b7a72d72e9708cbbcff5591e3ac17858c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / ferronit-0.22.0-cp312-abi3-manylinux_2_28_x86_64.whl

Download URL ferronit-0.22.0-cp312-abi3-manylinux_2_28_x86_64.whl
Size 482.5 kB
Tags CPython 3.12 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
75b37dc95ca38f232c1b2bdd9e69e8d6eaebf90e95c0f14bbcd88abcc9a8efc9
BLAKE2b-256 checksum
How to use checksums
16cf4fe9f306c7eee11f5126db9bacb044fad4ddcf01b46380dff31cded8d811
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / ferronit-0.22.0-cp312-abi3-manylinux_2_28_aarch64.whl

Download URL ferronit-0.22.0-cp312-abi3-manylinux_2_28_aarch64.whl
Size 466.1 kB
Tags CPython 3.12 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
a5eebc22daf596da0508dba99d16688e6c50d474622907a737cb06bcf73292c2
BLAKE2b-256 checksum
How to use checksums
869167f2c72b4f0ab9c0b4901a68ec9cb4f183646f7ee8c099a7b7d5294308ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / ferronit-0.22.0-cp312-abi3-macosx_11_0_arm64.whl

Download URL ferronit-0.22.0-cp312-abi3-macosx_11_0_arm64.whl
Size 443.6 kB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5b8d254110d5f06269dfef7b77bbf5fedaf2d89a27cb9b7e3cdde99ff2df18d5
BLAKE2b-256 checksum
How to use checksums
5755bda4ac4ec1445576ee478e2e3a596815fb875db5277508a00fd0a9c7db45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / ferronit-0.22.0-cp312-abi3-macosx_10_12_x86_64.whl

Download URL ferronit-0.22.0-cp312-abi3-macosx_10_12_x86_64.whl
Size 453.8 kB
Tags CPython 3.12 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
3c1415948e18eb11aeb220a2cd26bd08b40ad1dd06fca1b263fc5400aaa5c6de
BLAKE2b-256 checksum
How to use checksums
72cd06cafdafa9b94471b3403a484abf1a64efde71f93f812522766cb7c03c74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for ferronit 0.22.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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