Skip to content

perf: reuse decorator-owned static body TypeAdapters - #611

Merged
yeongseon merged 3 commits into
mainfrom
perf/static-body-adapter
Oct 26, 2026
Merged

yeongseon merged 3 commits into
mainfrom
perf/static-body-adapter

Conversation

@yeongseon

Copy link
Copy Markdown
Owner

Summary

Prepare static body TypeAdapters once for default Pydantic decorators without changing the custom adapter API.

Changes

Keep one private model-identity/adapter pair per default decorator. Direct adapter calls and supplied custom adapters retain existing parsing behavior; query still uses model_validate. Failed preparation preserves request-time behavior. Add failing-first no-reconstruction regression and custom body/query compatibility control, plus repeatable benchmark and cost documentation.

Validation

Python 3.11 make check-all build: 811 passed, 27 deselected, 4 warnings in 18.12s; coverage 97.22%. Benchmark (Python 3.11.15/Pydantic 2.14.1, minimum of five 10k runs): small model 5.638 to 0.728 us; nested 6.223 to 1.225 us; union 75.183 to 1.000 us. Adapter-only, not HTTP latency. Existing cross-handler, custom backend and worker tests pass. GitHub CI pending.

Related Issues

Closes #595

Merge authorized by the maintainer’s explicit instruction.

@yeongseon

Copy link
Copy Markdown
Owner Author

Merge authorized by the maintainer’s explicit instruction. Reviewed per-decorator ownership, model identity guard, custom-adapter bypass and benchmark limits. Exact head 356fbe6: five required contexts completed=success, no unresolved threads. Local summary: 811 passed, 27 deselected, 4 warnings in 18.12s; 97.22% coverage.

@yeongseon
yeongseon merged commit 206720a into main Oct 26, 2026
25 checks passed
@yeongseon
yeongseon deleted the perf/static-body-adapter branch October 26, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(request): benchmark and reuse body TypeAdapters where safe

1 participant