At the moment, jsonschema supports only serde_json, which is convenient, but implies significant overhead in some cases. For example, in Python bindings, I got to convert Python structures to serde_json::Value first and this conversion takes up to 85% of the overall validation time. It will be much faster if those Python objects will be used directly without conversion.
It could be done with a generic Json trait that will implement some API on the input data (likely similar to serde_json). In this case, implementing Json on a newtype wrapper around PyAny will eliminate the need for conversion. Additionally, it will reduce the memory footprint as no copying will be needed.
For existing serde_json data it should be optimized away as the wrapper will just delegate the calls to serde_json::Value.
At the moment,
jsonschemasupports onlyserde_json, which is convenient, but implies significant overhead in some cases. For example, in Python bindings, I got to convert Python structures toserde_json::Valuefirst and this conversion takes up to 85% of the overall validation time. It will be much faster if those Python objects will be used directly without conversion.It could be done with a generic
Jsontrait that will implement some API on the input data (likely similar toserde_json). In this case, implementingJsonon a newtype wrapper aroundPyAnywill eliminate the need for conversion. Additionally, it will reduce the memory footprint as no copying will be needed.For existing
serde_jsondata it should be optimized away as the wrapper will just delegate the calls toserde_json::Value.