A blazingly fast Rust-based FastAPI alternative
Project description
Blazely
A high-performance web framework combining Rust's speed with Python's simplicity.
Performance: 2.7x faster than FastAPI in single-threaded scenarios, with ultra-low latency (0.5ms vs 1.4ms).
Features
- ๐ Rust-Powered: Hyper HTTP server + Tokio async runtime
- โก Fast JSON: Native Rust serde_json serialization (3-5x faster than Python)
- ๐ Free-Threading Ready: PyO3 0.23 with
gil_used = false - ๐ฏ Multi-Threading: True concurrent request handling
- ๐ Python-Friendly: FastAPI-like decorator syntax
- ๐ฆ Easy Install: Single
pip installwith pre-built wheels (planned)
Quick Start
Prerequisites
- Python 3.13+ (or 3.8+, but 3.13 recommended)
- Rust toolchain (install here)
Installation
# Clone the repository
git clone https://github.com/cakirtaha/blazely.git
cd blazely
# Install dependencies and build
pip install maturin
maturin develop --release
# Or use uv (recommended)
uv pip install maturin
uv run maturin develop --release
Hello World
from blazely import Blazely
app = Blazely()
@app.get("/")
def hello(request=None):
return {"message": "Hello, Blazely!"}
if __name__ == "__main__":
app.run() # Server starts on http://127.0.0.1:8000
Architecture
Two-Layer Design
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Python Layer โ FastAPI-like API
โ - Decorators (@app.get) โ Easy to use
โ - Type hints & Pydantic โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ
โ PyO3 0.23 Bridge
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโ
โ Rust Layer โ Performance
โ - Hyper HTTP/1.1 server โ Low latency
โ - Tokio multi-threading โ High throughput
โ - serde_json โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Request Flow
- HTTP Request โ Hyper receives (Rust, no GIL)
- Route Matching โ matchit finds handler (Rust, no GIL)
- Python Handler โ Acquire GIL, call your function
- JSON Response โ serde_json serializes (Rust)
- HTTP Response โ Hyper sends, release GIL
Key Insight: GIL is held only during your Python handler execution (~1ms)
Performance
Benchmark Results
Test: 150 requests to GET / endpoint (simple JSON response)
| Metric | Blazely | FastAPI | Improvement |
|---|---|---|---|
| Single-threaded | 1,935 req/s | 714 req/s | 2.71x faster |
| Multi-threaded (10) | 2,890 req/s | 2,665 req/s | 1.08x faster |
| Latency (avg) | 0.50ms | 1.38ms | 2.76x lower |
Why So Fast?
- Rust serde_json - All JSON in compiled code (not Python)
- Hyper - Low-level HTTP server (minimal overhead)
- Minimal GIL - Python only during handler execution
- Multi-threading - Tokio handles concurrency efficiently
API Reference
Creating an Application
from blazely import Blazely
app = Blazely(title="My API", version="1.0.0")
Route Decorators
@app.get("/path") # GET request
@app.post("/path") # POST request
@app.put("/path") # PUT request
@app.delete("/path") # DELETE request
@app.patch("/path") # PATCH request
Path Parameters
@app.get("/users/{user_id}")
def get_user(request=None, user_id: int = 0):
# Extract from request if needed
if request and "path_params" in request:
user_id = int(request["path_params"]["user_id"])
return {"user_id": user_id}
Query Parameters
@app.get("/search")
def search(request=None, q: str = "", limit: int = 10):
# Extract from request if needed
if request and "query_params" in request:
q = request["query_params"].get("q", q)
limit = int(request["query_params"].get("limit", limit))
return {"query": q, "limit": limit}
Request Body (Pydantic)
from pydantic import BaseModel
class Item(BaseModel):
name: str
price: float
@app.post("/items")
def create_item(request=None, item: Item = None):
# Request body is parsed and validated
if request and "body" in request:
item = Item(**request["body"])
return {"item": item.model_dump()}
Const Routes (Ultra-Fast)
@app.get("/health", const=True)
def health(request=None):
return {"status": "ok"}
Response is cached in Rust and served without calling Python. Expected: 100k+ req/s.
Project Structure
blazely/
โโโ python/blazely/ # Python API layer
โ โโโ app.py # Main Blazely class with decorators
โ โโโ response.py # Response types
โ โโโ params.py # Parameter extractors
โ โโโ _internal.py # Imports Rust extension module
โ
โโโ src/ # Rust performance engine
โ โโโ lib.rs # PyO3 module entry point
โ โโโ server.rs # Hyper HTTP server + Tokio runtime
โ โโโ router.rs # Route matching with matchit
โ โโโ handler.rs # Python handler bridge (GIL management)
โ โโโ request.rs # HTTP request โ Python dict
โ โโโ response.rs # Python dict โ HTTP response (serde_json)
โ โโโ runtime.rs # Tokio runtime creation
โ
โโโ examples/
โ โโโ hello_world.py # Simple example application
โ
โโโ Cargo.toml # Rust dependencies
โโโ pyproject.toml # Python package config (Maturin)
Technology Stack
Rust (Performance Layer)
- PyO3 0.23 - Python/Rust bindings with free-threading support
- Hyper 1.0 - Low-level HTTP server
- Tokio - Multi-threaded async runtime
- serde_json - Fast JSON serialization
- matchit - Fast path routing
- pythonize - Python โ serde conversion
Python (API Layer)
- Pydantic - Data validation
- typing-extensions - Type hints
Development
Building
# Development build (faster compilation)
maturin develop
# Release build (optimized, slower compilation)
maturin develop --release
# With uv (recommended)
uv run maturin develop --release
Running Tests
# Python tests
pytest tests/python/
# Rust tests
cargo test
Running Examples
python examples/hello_world.py
# Visit http://127.0.0.1:8000
Current Status
โ Working
- HTTP server (Hyper + Tokio)
- Route decorators (@app.get, @app.post, etc.)
- Path and query parameters
- Request body with Pydantic
- JSON responses (serde_json)
- Const route caching
- Multi-threading support
- Free-threading compatible (Python 3.13t ready)
โ ๏ธ Limitations
- Handlers must accept
requestparameter - Even if unused:def handler(request=None) - Async handlers not fully supported - Use sync handlers for now
- Parameter extraction manual - Need to extract from
requestdict - No middleware - Coming in future versions
- No OpenAPI generation - Coming in future versions
๐ฏ Roadmap
- Automatic parameter injection (remove manual extraction)
- Full async handler support
- Middleware system
- OpenAPI schema generation
- Request/Response classes (instead of dicts)
- WebSocket support
- Static file serving
Troubleshooting
Build fails
# Update Rust
rustup update
# Clean and rebuild
cargo clean
maturin develop --release
Import error: blazely._internal
# Rebuild the extension
maturin develop
Server not responding
Make sure handlers accept the request parameter:
# โ Wrong
@app.get("/")
def handler():
return {}
# โ
Correct
@app.get("/")
def handler(request=None):
return {}
Contributing
Contributions welcome! Key areas:
- Performance - Optimize hot paths
- Features - Middleware, OpenAPI, async support
- Testing - More integration tests
- Documentation - Examples and guides
License
MIT License - see LICENSE file
Acknowledgments
- Built with PyO3 - Amazing Rust/Python interop
- Inspired by FastAPI - Great API design
- Powered by Hyper - Rust's HTTP foundation
Blazely = Rust's speed + Python's simplicity ๐
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file blazely-0.1.1.tar.gz.
File metadata
- Download URL: blazely-0.1.1.tar.gz
- Upload date:
- Size: 64.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f37b5c10b7363d1369a79d63129ce8ed66e50a07b8256c926d720505de216757
|
|
| MD5 |
83548c6ab4322c5df5c6997e78af251e
|
|
| BLAKE2b-256 |
71e489dea470fade60ff7fe529abfcf155fb924e503f5b3cef0a7cd2ef4e5d5b
|
Provenance
The following attestation bundles were made for blazely-0.1.1.tar.gz:
Publisher:
ci.yml on cakirtaha/blazely
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
blazely-0.1.1.tar.gz -
Subject digest:
f37b5c10b7363d1369a79d63129ce8ed66e50a07b8256c926d720505de216757 - Sigstore transparency entry: 962627135
- Sigstore integration time:
-
Permalink:
cakirtaha/blazely@556d9d58e9d9ffdcdee8aa895c7a0766a5f4692c -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/cakirtaha
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@556d9d58e9d9ffdcdee8aa895c7a0766a5f4692c -
Trigger Event:
push
-
Statement type:
File details
Details for the file blazely-0.1.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: blazely-0.1.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 578.4 kB
- Tags: PyPy, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27a24d46d08fed22119be538b26180f2d65fbfdae86d4add07b7d723e68bbbcc
|
|
| MD5 |
628da84b9bdb189e89bdeb6626e87e33
|
|
| BLAKE2b-256 |
160fe407540ddc540d42e86ca167c9454acd13230fdc5aae859f9dcd2e6629f8
|
Provenance
The following attestation bundles were made for blazely-0.1.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
ci.yml on cakirtaha/blazely
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
blazely-0.1.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
27a24d46d08fed22119be538b26180f2d65fbfdae86d4add07b7d723e68bbbcc - Sigstore transparency entry: 962627171
- Sigstore integration time:
-
Permalink:
cakirtaha/blazely@556d9d58e9d9ffdcdee8aa895c7a0766a5f4692c -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/cakirtaha
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@556d9d58e9d9ffdcdee8aa895c7a0766a5f4692c -
Trigger Event:
push
-
Statement type:
File details
Details for the file blazely-0.1.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: blazely-0.1.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 579.3 kB
- Tags: PyPy, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a87f804cf8accf19f8c5a8d0662e414d2465858c54f9b52fa775c3acf7e62663
|
|
| MD5 |
6a697d462a43ad63d7bb90bde35e37b2
|
|
| BLAKE2b-256 |
138efe05e848205955816360df27438a0e2bc4cc4778548755fa0fa6ad9cdfeb
|
Provenance
The following attestation bundles were made for blazely-0.1.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
ci.yml on cakirtaha/blazely
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
blazely-0.1.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
a87f804cf8accf19f8c5a8d0662e414d2465858c54f9b52fa775c3acf7e62663 - Sigstore transparency entry: 962627211
- Sigstore integration time:
-
Permalink:
cakirtaha/blazely@556d9d58e9d9ffdcdee8aa895c7a0766a5f4692c -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/cakirtaha
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@556d9d58e9d9ffdcdee8aa895c7a0766a5f4692c -
Trigger Event:
push
-
Statement type:
File details
Details for the file blazely-0.1.1-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: blazely-0.1.1-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 548.3 kB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b92275cd083fea578f5e320bc050357eae61b397bef985174845513039d41e39
|
|
| MD5 |
55db78db13080ca17dd48222672428ce
|
|
| BLAKE2b-256 |
f66bcac1bdda5e6550fdf2ad000b79c6aa6b267db25fba28177093730e030af3
|
Provenance
The following attestation bundles were made for blazely-0.1.1-cp39-abi3-win_amd64.whl:
Publisher:
ci.yml on cakirtaha/blazely
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
blazely-0.1.1-cp39-abi3-win_amd64.whl -
Subject digest:
b92275cd083fea578f5e320bc050357eae61b397bef985174845513039d41e39 - Sigstore transparency entry: 962627158
- Sigstore integration time:
-
Permalink:
cakirtaha/blazely@556d9d58e9d9ffdcdee8aa895c7a0766a5f4692c -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/cakirtaha
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@556d9d58e9d9ffdcdee8aa895c7a0766a5f4692c -
Trigger Event:
push
-
Statement type:
File details
Details for the file blazely-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: blazely-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 606.6 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a1bfbf00de28bbd9c5da41046cf9f73783c83e7d773ccce26b0368e2872e0fa
|
|
| MD5 |
f4631688ddb2497f19e874b80346cd30
|
|
| BLAKE2b-256 |
2afc5d9c66e096342b8ba8834127806999f7df3da4fc76a3850f8202f226e9e0
|
Provenance
The following attestation bundles were made for blazely-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
ci.yml on cakirtaha/blazely
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
blazely-0.1.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
7a1bfbf00de28bbd9c5da41046cf9f73783c83e7d773ccce26b0368e2872e0fa - Sigstore transparency entry: 962627198
- Sigstore integration time:
-
Permalink:
cakirtaha/blazely@556d9d58e9d9ffdcdee8aa895c7a0766a5f4692c -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/cakirtaha
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@556d9d58e9d9ffdcdee8aa895c7a0766a5f4692c -
Trigger Event:
push
-
Statement type:
File details
Details for the file blazely-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: blazely-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 580.2 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f31808c2e424bdb62c3258b97d95b1eac58c4c068d30fa9da86bf0bda8636ecc
|
|
| MD5 |
3c3798a3e2db1ac807c7ca0665a36a78
|
|
| BLAKE2b-256 |
e1f9d259891021fec996ad1a492a1ce2211a72d5337b900e457acbb8ce89e54d
|
Provenance
The following attestation bundles were made for blazely-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
ci.yml on cakirtaha/blazely
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
blazely-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
f31808c2e424bdb62c3258b97d95b1eac58c4c068d30fa9da86bf0bda8636ecc - Sigstore transparency entry: 962627183
- Sigstore integration time:
-
Permalink:
cakirtaha/blazely@556d9d58e9d9ffdcdee8aa895c7a0766a5f4692c -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/cakirtaha
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@556d9d58e9d9ffdcdee8aa895c7a0766a5f4692c -
Trigger Event:
push
-
Statement type:
File details
Details for the file blazely-0.1.1-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: blazely-0.1.1-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 546.1 kB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7aaf5474c1672785258ec0f9103462ffe15aae2ff181edcd29ef9edd372d11f
|
|
| MD5 |
7094229fcc4351a2a9d7ac1638259c31
|
|
| BLAKE2b-256 |
6593a70111d13b5c26a74bf2abba3fe55007c58d2bd6b79c915521aaefb0f210
|
Provenance
The following attestation bundles were made for blazely-0.1.1-cp39-abi3-macosx_11_0_arm64.whl:
Publisher:
ci.yml on cakirtaha/blazely
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
blazely-0.1.1-cp39-abi3-macosx_11_0_arm64.whl -
Subject digest:
a7aaf5474c1672785258ec0f9103462ffe15aae2ff181edcd29ef9edd372d11f - Sigstore transparency entry: 962627147
- Sigstore integration time:
-
Permalink:
cakirtaha/blazely@556d9d58e9d9ffdcdee8aa895c7a0766a5f4692c -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/cakirtaha
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@556d9d58e9d9ffdcdee8aa895c7a0766a5f4692c -
Trigger Event:
push
-
Statement type: