pydantic-core
pydantic-core copied to clipboard
separation of validation and python interface
Hi!
I have been a long time user of pydantic (great library btw) and have been following the development of the rust library.
I was wondering if it would make sense/would be possible to separate the python related code (use of Py* etc.) and rust implementation.
That way it'd be possible to use this great library not only in python code, but also port it to e.g. js or use for validation of rust code.
I'd be happy to take a stab at it and create a PR - if wanted.
I've thought about this a lot, not just for rust validation but for an entirely theoretical "tydantic" package, see #10.
The problem is that in rust dyn means heap and heap means slow, and I'm not willing to give up performance for this.
The only way to do it would be as a compile time config setting I think.
If you're experienced with rust and really think you can do it elegantly (with minimal cognitive or verbosity overhead for future development and maintenance) feel free to have a go, but I should warn you - while I too really want this, the bar for accepting such a change is high. I'm very aware that what I'm trying to do here is already a massive task for (mostly) one developer, I want to avoid mission creep.
The other thing to say is that you can't really separate the two things - python types are used throughout the library doing otherwise would hammer performance.
Thanks for the quick response and the additional info.
I think it's doable, but challenging, given the obvious and justified constraints, but I'd like to give it a try over the next coming days/weeks anyways.
Glad to see that I am not the only one that is interested in such a change.
Sounds good. Let me know when something is ready to review, best to fail early if we're going to fail.
#71 is a better discussion of these issues.