You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf: avoid double-AST allocation for JSON bodies and leverage Pydantic model_validate_json #255
Where: src/dispatch.rs:889-908, 1217-1250 and src/schema.rs:49-53 (json_to_py).
Currently, JSON request bodies follow this path:
serde_json::from_slice::<JsonValue>(&body_bytes) constructs a full Rust AST (serde_json::Value), allocating every map, array, and string on the Rust heap.
json_to_py traverses the Rust AST and allocates a duplicate Python AST (PyDict, PyList, PyString).
If body_model is present, model_validate(pyv) is called on the Python dictionary.
Fix direction:
When a Pydantic model (body_model) is configured, call model_validate_json(body_bytes) directly. Pydantic v2 parses JSON in Rust/C via pydantic-core 5-10x faster with zero intermediate Python dict allocations.
When no Pydantic model is present, deserialize bytes directly to Python objects without the intermediate serde_json::Value Rust AST.
Activity
Merge pull request #262 from QueryaHub/issue-255-pydantic-model-valid…
ZhuchkaTriplesix commentedon Oct 18, 2026
Resolved in PR #262