Static-response cache — Wave 4
Handlers whose body is exactly return SomeResponse(literal_args) with no parameters now have their two ASGI messages built once at registration time via AST inspection and re-emitted directly on every request — no handler call, no Response allocation, no header construction per request.
Micro-benchmark (Darwin / Python 3.13, ASGI-level)
| Per-request | Throughput | |
|---|---|---|
| Wave 3 trivial fast path (0.1.6) | 6.76 µs | 148 k req/s |
| Wave 4 static cache (0.1.7) | 0.89 µs | 1 126 k req/s |
7.5× speedup at the framework level. Real HTTP-server overhead (Granian + wrk) dominates per-request time at this point — we expect the Linux competitive bench to take #1 in plaintext away from BlackSheep (which currently leads at 165 k req/s).
Detection (AST-only, no handler invocation at registration)
- No parameters of any kind
- Single
returnstatement (optional docstring before it) - Return value is
CalltoResponse/PlainTextResponse/JSONResponse/HTMLResponseby bare name - All positional and keyword arguments are literals (
Constant/ list / tuple / set / dict / unary +/- of constants)
Any deviation falls through to the existing trivial / general fast paths — no behavioural regression for dynamic handlers.
Added
- README now leads with a Why HawkAPI matrix (Performance / Production rigor / Features no one else has) and a dedicated p99 latency table showing tail-behaviour wins.
Full changelog: https://github.com/ashimov/HawkAPI/blob/v0.1.7/CHANGELOG.md