The fastest Python web framework.
Project description
necro
The fastest Python web framework.
The fastest HTTP/1.1 web server, period! 🧟♀️ 💨
Speed
Under maximum load from 4K users:
⎿ Summary:
Success rate: 100.00%
Total: 10,005.1308 ms
Slowest: 90.9730 ms
Fastest: 0.0117 ms
Average: 0.6949 ms
Requests/sec: 1,453,431.8677
Total data: 416.02 MiB
Size/request: 30 B
Size/sec: 41.58 MiB
Response time distribution:
10.00% in 0.1609 ms
25.00% in 0.1992 ms
50.00% in 0.2903 ms
75.00% in 0.7278 ms
90.00% in 1.6830 ms
95.00% in 2.8445 ms
99.00% in 4.7198 ms
99.90% in 7.2662 ms
99.99% in 9.7244 ms
Memory:
startup: 63 MB
after warmup: 93 MB
under load: 105 MB
peak RSS: 105 MB
Benchmarked on consumer hardware. No pipelining!
Comparisons with simple json payloads:
server req/s avg latency
necro 1,514,316 240 µs
nginx 1,310,342 261 µs
fasthttp (Go) 1,142,127 351 µs
uvicorn, bare ASGI 556,123 441 µs
granian, bare ASGI 549,132 445 µs
Go net/http stdlib 502,746 684 µs
uvicorn + litestar 260,007 0.97 ms
uvicorn + starlette 50,976 5.01 ms
uvicorn + fastapi 29,852 8.56 ms
Simple
A familiar developer experience:
import necro
app = necro.App()
@app.get("/")
async def raise():
return {"message": "the dead rise"}
app.run()
necro run app:app
Postgres
Built-in first-class Postgres support!
import necro
app = necro.App()
@app.get("/summon/{id}")
async def summon_one(db, id):
return await db.fetch_one("SELECT id, name, power FROM minions WHERE id = $1", id)
@app.post("/raise")
async def raise_dead(db, body):
return await db.execute(
"INSERT INTO minions (name, power) VALUES ($1, $2)",
body.name,
body.power
)
app.run()
Redis
Built-in first-class Redis support!
import necro
app = necro.App()
@app.post("/bind")
async def bind(redis, body):
await redis.set(body.name, body.soul)
await redis.expire(body.name, 3600)
return {"bound": body.name, "ttl": 3600}
app.run()
Type-safe SQL
The framework's recommended approach to using the db.
Highly optimized!
Define your schema:
-- undead.sql
CREATE TABLE zombies (
id SERIAL PRIMARY KEY,
decay_rate REAL,
graveyard TEXT,
);
Define your queries:
-- spells.sql
-- name: SummonZombie :one
SELECT * FROM zombies WHERE id = {id};
-- name: RaiseHorde :many
SELECT * FROM zombies ORDER BY decay_rate ASC;
!!! info Did you know Claude's best language is SQL?
Generate methods and models, complete with type hints and validations:
necro scribe
generates:
# undead.py
class Zombie(NecroModel):
id: int
decay_rate: float
graveyard: str
Now the db will have your queries:
await db.spells.summon_zombie(id=id)
await db.spells.raise_horde()
Serve type-safe results from your routes:
import necro
app = necro.App()
@app.post("/summon")
async def raise_horde(spells) -> list[Zombie]:
return await spells.raise_horde()
app.run()
OpenAPI
Validations
Client
Websockets
One dependency
pip install necro
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 Distributions
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 necro-0.0.4-cp314-cp314-manylinux_2_17_x86_64.whl.
File metadata
- Download URL: necro-0.0.4-cp314-cp314-manylinux_2_17_x86_64.whl
- Upload date:
- Size: 166.3 kB
- Tags: CPython 3.14, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c584cca209f8418928160cfb31fb9e410ce458e12b821e585c0898957db5a777
|
|
| MD5 |
0a411799e8dea9f3c0842fb79b84e3d6
|
|
| BLAKE2b-256 |
d919be2282c4d444e4985a168ba652887eb07828ab00aa1ef1e44922eea88927
|
File details
Details for the file necro-0.0.4-cp314-cp314-manylinux_2_17_aarch64.whl.
File metadata
- Download URL: necro-0.0.4-cp314-cp314-manylinux_2_17_aarch64.whl
- Upload date:
- Size: 162.9 kB
- Tags: CPython 3.14, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48df10add57fc1a4a35ae7744b553def311794130b1d074c15b35bdd9db1a34e
|
|
| MD5 |
92f87e035927763b5e53d45e70619239
|
|
| BLAKE2b-256 |
12dc4b5438cf2b2c9bdbee65827a64c4db6f60aea06d2bf205e65cd428607485
|
File details
Details for the file necro-0.0.4-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: necro-0.0.4-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 135.4 kB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9e0a99999e39f8ede564fd272e98d773e28110fb8f61b23e022b75953653930
|
|
| MD5 |
52a37f8b438f33c1d2964c5b5f75e4b9
|
|
| BLAKE2b-256 |
4009dbd8e521b650bf4bb073b3bebb430c6296f6962df16bd8972d699187c07e
|