Skip to main content

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  (pools allocated, sub-interpreters created)
    under load: 105 MB   (stable, no growth)
    peak RSS:   105 MB

Benchmarked on consumer hardware.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

necro-0.0.0.dev2-cp314-cp314-manylinux_2_17_x86_64.whl (172.7 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

necro-0.0.0.dev2-cp314-cp314-manylinux_2_17_aarch64.whl (169.8 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ ARM64

necro-0.0.0.dev2-cp314-cp314-macosx_11_0_arm64.whl (134.2 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

File details

Details for the file necro-0.0.0.dev2-cp314-cp314-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for necro-0.0.0.dev2-cp314-cp314-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 7900d02bdd2305136ef56f7236657cb292f03e9ffde568058d6d3ca461116c03
MD5 bd9a50854e917eeb3ddca92ca7209fef
BLAKE2b-256 eebd8b353d32f6b0fd5e60d3d3ca0951fd8c5b0838ff11e97c81e0ff9fedf235

See more details on using hashes here.

File details

Details for the file necro-0.0.0.dev2-cp314-cp314-manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for necro-0.0.0.dev2-cp314-cp314-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 b3d53070e5309fcf2674904935da10930898a56a5e1befdf33b4abfa9ab46d63
MD5 0e1d6725a0e4a2fa97f15772a84b1957
BLAKE2b-256 df7478bcd81eb49cfb08aba1f4dacb3717acb93645bf2a628ab56b33929462c4

See more details on using hashes here.

File details

Details for the file necro-0.0.0.dev2-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for necro-0.0.0.dev2-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 db559e51bce284f1e39beecf2df03a86ebc70709d808cb4fe2a49cebf2244e94
MD5 10046a2da3ff7f4786ebdba5d5548c7b
BLAKE2b-256 e75b8f07c777343fff3a8517577603a6b022351e532ea1562f6ed444bba96e4c

See more details on using hashes here.

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