Skip to content

Commit af4929a

Browse files
committed
docs: correct cache details in inlined decoder rationale
1 parent 1fb6263 commit af4929a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎docs/engineering.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ A protocol seam is a documented internal boundary. AI agents and contributors mu
3737

3838
- **Where:** `src/httpware/client.py` ↔ `src/httpware/decoders/`.
3939
- **Contract:** the decoder is invoked when the caller passes `response_model=`. The protocol is `decode(content: bytes, model: type[T]) -> T`.
40-
- **Rule:** the decoder must operate on raw bytes in a single parse pass. Two-pass decoding (`json.loads` then `validate_python`) is rejected: a single bytes-in / typed-object-out pass avoids the redundant intermediate `dict` allocation and parses faster. The Pydantic adapter implements this as `TypeAdapter(model).validate_json(content)` with `@functools.lru_cache(maxsize=None)` on `TypeAdapter` construction (the adapter object is the expensive part to build, keyed by `model`). The msgspec adapter implements it as `msgspec.json.decode(content, type=model)`.
40+
- **Rule:** the decoder must operate on raw bytes in a single parse pass. Two-pass decoding (`json.loads` then `validate_python`) is rejected: a single bytes-in / typed-object-out pass avoids the redundant intermediate `dict` allocation and parses faster. The Pydantic adapter implements this as `TypeAdapter(model).validate_json(content)`, with the `TypeAdapter` itself memoized via `@functools.lru_cache(maxsize=1024)` on a module-level `_get_adapter(model)` factory (the adapter is the expensive part to build). The msgspec adapter implements it as `msgspec.json.decode(content, type=model)`.
4141

4242
### Seam 4: `Httpx2Transport ↔ httpx2`
4343

0 commit comments

Comments
 (0)