Skip to main content
Wreath

Wreath

Many separate parts, gathered and woven until they hold a single shape.

Python 3.14+ ASGI HTTP 1.1, 2, 3 Runtime dependencies: zero License: MPL-2.0

A Python 3.14-first ASGI framework, PostgreSQL stack, job system, policy engine, and native HTTP server. One package; no mandatory runtime dependencies.

Documentation · Browse by task · Install · Issues


One system. One obvious home.

A production web service needs more than a router. It needs validation and data access. It also needs identity, policy, background work, observability, and a server. Wreath ships those parts together and names each module after the job it does: wreath.pagination paginates, wreath.jobs runs jobs, and wreath.email sends mail.

The imagery belongs to the name. The API stays literal.

from wreath import Request, Wreath

app = Wreath()

@app.get("/hello/{name}")
async def hello(request: Request, name: str) -> dict:
    return {"hello": name}
wreath run app:app          # native HTTP server
wreath dev app:app          # native server with reload
uvicorn app:app             # or any conforming ASGI server

Wreath is pre-1.0. Shipped surfaces are implemented and tested. Work that is named but not finished lives only in the roadmap.

Choose your route

You want to… Start here
build your first service Installation and first app
find one feature or concept Documentation map
complete a concrete task Cookbook
look up a class or function API reference
move from FastAPI, Pydantic, SQLModel, or Alembic Migration path
evaluate the dependency or performance claim Capability map and measurements

The published site keeps Browse in its header on every page. Search is Ctrl K or /.

What ships

Part of the service Wreath owns
request path ASGI application, routing, binding, validation, middleware, responses, OpenAPI, typed clients
identity and policy sessions, JWT and API keys, OAuth/OIDC, users, TOTP, passkeys, Cedar authorization
data native PostgreSQL driver, ORM, migrations, safe SQL, vector and full-text search, pagination
long-running work durable jobs, schedules, messaging, workflows, resumable streams, progress
service boundaries outbound HTTP, webhooks, MCP, object storage, signatures, provenance, email
operations native HTTP/1.1, HTTP/2 and HTTP/3 server, health, telemetry, logging, replay, testing

The full generated inventory says what each part replaces and links to its guide: what you do not have to install.

Native gzip, shaped to the document

Wreath owns both halves of gzip. The encoder and decoder are independent native kernels: they share the RFC 1951/1952 wire format, not one duplex algorithm. When Content-Type is known, JSON, GraphQL, HTML, logs, plain text, and high-entropy JSON take separately compiled policies. The result is still ordinary gzip readable by browsers, zlib, zlib-ng, and libdeflate.

Retired userspace instructions per uncompressed byte at level 6, lower is better. Each cell is Wreath / libdeflate / zlib-ng:

Document Encode instr/B Decode instr/B Wreath encode L1D hit Wreath encode LLC hit
JSON 52.94 / 64.58 / 67.79 6.13 / 7.40 / 9.17 91.50% 85.62%
GraphQL 32.31 / 49.76 / 46.45 3.04 / 3.56 / 4.37 89.18% 90.38%
HTML 45.37 / 59.27 / 61.27 4.54 / 5.57 / 6.85 89.70% 87.75%
plain text 71.55 / 92.56 / 101.70 6.84 / 7.82 / 9.63 88.56% 93.45%
logs 50.37 / 62.97 / 67.06 6.12 / 7.55 / 9.33 92.22% 82.79%
high-entropy JSON 57.00 / 89.78 / 124.37 10.46 / 14.23 / 18.03 97.80% 99.03%
weighted corpus 50.88 / 67.18 / 71.96 5.62 / 6.82 / 8.44 — —

That is fewer encode and decode instructions in every document row. The cache figures are the 500 kB representatives: the high-entropy encoder retires only 4.13 LLC misses/kB, while the regular-document decoder stays at 1.79–2.22 LLC misses/kB with a 97.86–98.17% LLC hit rate. Across the corpus, Wreath's output is 0.33% larger than zlib-ng's and 0.80% larger than libdeflate's—the ratio cost kept beside the instruction win rather than hidden.

The comparison uses repository-native boundaries, application- or stream-owned warm contexts, six document sizes from 10 kB through 1 MB (the high-entropy case is 500 kB), and hardware performance counters on Linux x86-64 / Ryzen 7 7730U. A subsequent cache sweep over 30 JSON, GraphQL, HTML, text, and log documents chose the 32 Ki-entry format hash table and shallower per-format search limits: encode instructions fell 4.79%, L1D misses 12.87%, and LLC misses 52.07% on the same corpus. The shipped balance retires 49.04 encode instructions/byte with 91.62% L1D and 93.92% LLC hit rates; output is 23.71% of input. No elapsed time, cycles, or IPC enters either result. The repository retains the measurement data.

One real request, all the way through

This is not a plaintext race or a synthetic JSON payload. All three configurations render the same operations-intelligence dashboard from one successful request: HTTP policy and sessions, nested typed input, bearer authentication, Cedar, overlapping PostgreSQL and HTTP wire calls, a sparse-to-dense 730-day × 48-tenant × 6-measure projection, eleven chart paths, temporal, geospatial and vector work, ranked pagination, protobuf and MessagePack exports, an escaped template, compression, and HTML emission.

Retired userspace instructions per request, lower is better:

Wreath: DCZ + fragment gzip  ▌                                               2,426,742
Wreath: format-aware gzip    █                                               4,690,494
FastAPI: gzip                ████████████████████████████████████████████████  226,270,075

Format-aware Wreath retired 48.24× fewer instructions than FastAPI in this run. The dictionary-aware configuration retired 93.24× fewer instructions, removing 2,263,752 instructions per request—a further 48.26% from Wreath's full request path. Its selected response is RFC 9842 dcz: a real response for neighbouring resource 41 is the client-held dictionary for resource 42, whose 35,805-byte body differs at only two bytes. The same configuration falls back to standard concatenated gzip members for ordinary clients, recompressing the 249-byte dynamic prefix while reusing the independently readable stable member. It does not claim that DCZ and gzip are nested in one response.

All three rows use TLS 1.3 over HTTP/1.1 and are medians of five alternating 30/15-request slopes. Ranges were 4,673,133–4,696,949 for format-aware Wreath, 2,416,962–2,447,953 for the dictionary-aware configuration, and 226,205,485–226,918,987 for FastAPI. The unchanged A/A controls differed from their medians by 0.03%, 0.10%, and 0.11%, respectively. The harness accepts a DCZ sample only after checking its dictionary hash, decoded response facts, secure transport, and both required Vary fields; it separately exercises and decodes the fragment-gzip fallback before attaching counters.

The FastAPI implementation is not a slow pure-Python foil. It uses the ecosystem stack a pragmatic service would assemble: Starlette policy middleware, Pydantic, Uvicorn/uvloop/httptools, HTTPBearer, cedarpy, asyncpg, aiohttp, NumPy, Jinja, protobuf, and msgspec. Wreath performs the corresponding transaction through its dependency-free declarative surfaces and native data kernels.

To make the framework layers independently auditable, a smaller companion request removes the dashboard calculations while keeping the same successful routing, CORS, validation, auth, Cedar, PostgreSQL, HTTP, and JSON path:

The cumulative decomposition shows where work enters:

Successful request includes Wreath FastAPI stack
route + JSON response 36,006 426,899
+ CORS 47,156 490,826
+ typed binding and validation 115,305 776,764
+ bearer authentication 122,448 867,935
+ Cedar authorization 173,902 1,597,272
+ PostgreSQL query 225,857 1,809,675
+ outbound HTTP 269,110 2,133,383

On this stripped companion, Wreath retired 7.93× fewer instructions. Its purpose is decomposition; the holistic request above is the headline system comparison.

Arm Installed stack
Wreath Wreath 0.3.2 for the holistic arm (0.3.1 for the retained cumulative control): metal server, binding, auth, startup-compiled Cedar, PostgreSQL, and HTTP client; no mandatory third-party runtime dependencies
FastAPI FastAPI 0.139, Starlette, Pydantic/pydantic-core, Uvicorn, uvloop, httptools, HTTPBearer, cedarpy, asyncpg, aiohttp, NumPy, Jinja, protobuf, and msgspec

CORS is Starlette's CORSMiddleware, which FastAPI already brings in. It is not padded into the stack as another package. cedarpy 4.8.7 has a stateless public authorization call and no reusable compiled-policy handle. The measured request therefore includes that public lifecycle.

Both clients speak their real wire protocols to the same deterministic, in-process PostgreSQL and HTTP peers. The verifier rejects a sample unless the security, CORS, session, compression, and business response facts agree. Imports, startup, compilation, pool creation, and warm-up cancel through N/N/2 slopes. Server and generator are pinned separately with PYTHONHASHSEED=0. The result contains no elapsed time, cycles, or IPC. It was recorded on CPython 3.14.7 and Linux x86-64, on a Ryzen 7 7730U. SIMD dispatch can make another architecture retire a different count.

Reproduce it:

uv sync --inexact --group benchmark
uv run python -m benchmarks.bench_holistic_stack_instructions \
  --requests 30 --trials 5 --connections 8 --warmup 16 \
  --output docs/perf/data/e2e-holistic-stack-instructions.json

# The cumulative framework-layer control
uv run python -m benchmarks.bench_e2e_instructions \
  --requests 4000 --trials 5 --connections 32 --warmup 500 \
  --output docs/perf/data/e2e-stack-instructions.json

The repository retains the holistic raw samples, Wreath application, FastAPI application, and counter harness, plus the cumulative control samples.

Install

pip install wreath
# or
uv add wreath

uv add 'wreath[linux]'     # io_uring reactor and native TLS on Linux
uv add 'wreath[h3]'        # HTTP/3; `http3` is an alias

The base wheel includes Wreath's portable C implementation. The framework remains a conforming ASGI application when you use another server.

The engineering rule

Wreath moves repeated work out of requests and moves byte-heavy work into native kernels. It does not call an idea faster because it was rewritten in C. Every performance change starts with a measurement, keeps its controls, and reports the machine and method that produced the result.

The same refusal applies to correctness. Unsupported declarations fail at startup. Hot-path complexity has executable probes. The test runner samples declared controls and asks whether the suite notices when one disappears.

Read the request path for the design and performance for the numbers.

Work on Wreath

uv sync
uv run wreath-check
uv run wreath-check --docs
uv run wreath test

The repository's AGENTS.md is the engineering contract. The agent cookbook turns it into task-shaped routes through the tree.

Metadata

Release files for wreath 0.3.2

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

Built distributions (wheels)

Table of built distributions (wheels) for wreath 0.3.2
File
wreath-0.3.2-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
wreath-0.3.2-cp314-cp314-manylinux_2_26_x86_64.manylinux_2_34_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.34+ x86-64, Linux glibc 2.26+ x86-64 Details
wreath-0.3.2-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_34_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.34+ ARM64, Linux glibc 2.26+ ARM64 Details
wreath-0.3.2-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
wreath-0.3.2-cp314-cp314-macosx_10_13_x86_64.whl CPython 3.14 CPython 3.14 macOS 10.13+ x86-64 Details

Total release size: 29.0 MB

Release files / wreath-0.3.2-cp314-cp314-win_amd64.whl

Download URL wreath-0.3.2-cp314-cp314-win_amd64.whl
Size 4.5 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
db0604c027dd1b6928984b65e25ab4757f973299f79fa744d6a1620c7dd10777
BLAKE2b-256 checksum
How to use checksums
012de93ca6d89bf2ce56061952a60d6400151b5ee55d13f570693be17a553cd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 20, 2026.

Transparency log

Release files / wreath-0.3.2-cp314-cp314-manylinux_2_26_x86_64.manylinux_2_34_x86_64.whl

Download URL wreath-0.3.2-cp314-cp314-manylinux_2_26_x86_64.manylinux_2_34_x86_64.whl
Size 7.8 MB
Tags CPython 3.14 Linux glibc 2.26+ x86-64 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
6afcab1659cd5163948b3077c03f6c376eef2fb83730bc3695b1b37affa0d551
BLAKE2b-256 checksum
How to use checksums
fa09236da470f82b6c9a5332de24b96c3029030950f91287eee4fa53797a08e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 20, 2026.

Transparency log

Release files / wreath-0.3.2-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_34_aarch64.whl

Download URL wreath-0.3.2-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_34_aarch64.whl
Size 7.7 MB
Tags CPython 3.14 Linux glibc 2.26+ ARM64 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
dbabbf26b160e7a50a8115ddf69488f680ddede39e15139319f56682f2e5fe35
BLAKE2b-256 checksum
How to use checksums
58878622c4692d8fc0b213fae89e6ad04087cdde2d5466c2ba08f5e738f9d4b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 20, 2026.

Transparency log

Release files / wreath-0.3.2-cp314-cp314-macosx_11_0_arm64.whl

Download URL wreath-0.3.2-cp314-cp314-macosx_11_0_arm64.whl
Size 4.5 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6e197d12e6a9e89eee1eedbb0def95cfa5f776e2698fd1fb1846f59cf0f5002b
BLAKE2b-256 checksum
How to use checksums
713de46a6010fea3d8d7260715af8b3f024ec2bf2e220690f6dc9b39c7bf2db2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 20, 2026.

Transparency log

Release files / wreath-0.3.2-cp314-cp314-macosx_10_13_x86_64.whl

Download URL wreath-0.3.2-cp314-cp314-macosx_10_13_x86_64.whl
Size 4.6 MB
Tags CPython 3.14 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
1ce0defee341457cc99b3bb9884481268e89cbe551d947926a80315d4b9663ff
BLAKE2b-256 checksum
How to use checksums
e6698c7ebe035521a096e0792a696cf609a17ad889fc5edb37f086a7d2f3bb00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 20, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.0

5 release files

0.4.0

5 release files

0.3.4

5 release files

0.3.3

5 release files

This release

0.3.2 This release

5 release files

0.2.1

5 release files

0.2.0

6 release files

0.1.0a1

1 release file

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