Comments (5)
The options are:
- parse to python, then pass to
validate_python
which is fine, but slow - adding more formats to pydantic-core, this is fairly easy but will increase the binary size and have a maintenance burdon, so a format would need to be fairly widely used to be added - only yaml and toml could be considered I think
- We might be able to find some way to pass a
JsonInput
from rust to python, then back from python to rust in a safe way and thereby allow a library which pydantic-core doesn't know about create theJsonValue
with pydantic-core consumes - thereby getting most of the performance gain
But I don't know if that's possible, it would probably be "unsafe" e.g. if you passed a pointer to something other than a JsonValue
, you'd get a segfault. It's something to think about in future probably.
from pydantic-core.
If you have a model for "plugins" that's well developed, please explain - I can't see how that would work, but maybe I'm missing something.
from pydantic-core.
I am using Pydantic quite heavily in tandem with our own CBOR parsing code. It would be great if we could plug in an arbitrary serde
codec (such as ciborium
) rather than just serde-json. But I think using serde-json would be a great start.
from pydantic-core.
See also the work in orjson
which does a partial decode/encode of pydantic structures (but misses many of the fancier features).
As a total Rust noob, I made a POC fork of orjson with CBOR support: https://github.com/griels/orjson/tree/cbor-support-mk2 so it's quite simple to work in different codecs.
from pydantic-core.
Thanks, I'll have to think about it. It seems there isn't an obvious ABI Rust code can offer for 'plugins', short of wrapping in a C FFI (maybe something like the JSONInput you mention), so I guess otherwise serde codecs might have to be injected at the source code level. Perhaps there is someone who has already tackled this. Apologies for necroposting by the way! 'Plugging' ciborium
straight into Pydantic has been something I wanted to do for some time so I got excited.
from pydantic-core.
Related Issues (20)
- Worst case validation performance scales with the number of pydantic objects in memory HOT 4
- Unable to build Pydantic-Core 2.16.3 on Alpine 3.19 HOT 3
- Datetime underflow causes validation to fail HOT 1
- Different behavior for `extra_behavior` and `config.extra_fields_behavior`
- Add support for simple ser schema with `any` (`lambda x: x` replacement)
- Strict bug :( with config vs runtime flag
- False-positive `SchemaError` for keyword-only args: Non-default argument follows default argument
- 2.18.0: pep517 based build fails HOT 15
- `serialization` logic not regognized in `json` and `python` schemas at lower levels
- Make `validate_json` accept `memoryview`. HOT 1
- [BUG] Serializing datetime.time loses timezone data when datetime.datetime is reqired for utc offset because of DST HOT 1
- generate_self_schema.py incompatible with Python 3.13.0b1 HOT 3
- Unexpected behavior for Partial=True HOT 2
- UUID validators with custom string object HOT 1
- Fail to build pydantic_core on OS X 10.11 with Python 3.10 HOT 8
- 2.18.2: pytest fails in 3 units HOT 7
- Recursive serialization of UUID seems to fail json.dumps HOT 1
- Lower MSRV to 1.75
- `include` and `exclude` are not passed to field serializer contexts in function serializer HOT 1
- fail-fast list schema configuration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pydantic-core.