Skip to content

Commit 1fb6263

Browse files
committed
docs: inline decoder rationale before archive deletion
1 parent 37883ad commit 1fb6263

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 — see `archive/architecture.md` Validation & Decoding for rationale.
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)`.
4141

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

0 commit comments

Comments
 (0)