-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating Pydantic objects in Rust and passing to the interpreter. #1364
Comments
I'm the general case you can do this efficiently with pyo3. But I'm not sure how pydantic comes into it? If you're looking to implement your own types in rust, then validate them in pydantic in rust, I believe that's not currently possible. It's something we'd like to support one day, but I'm not sure how we'd go about it. |
Thank's for the reply! Apologies as this may be more pyo3 in general, but wondered since the core pydantic lib is rust-side. So we currently represent a bounding box in Python Space
In Pyo3 to implement this we could:
How would we retain NormBBox being a subclass of BaseModel? Are validation/serialization utilities available in Rust space? |
To subclass |
I made "Pydantic-like" objects from rust by "emulating" some of the features. My requirements were:
For that I created a macro attribute:
Where the
It definitely feels very hacky, but it worked for my use-case. The conversion from python dicts and json strings is done by using python's |
What's the best way to do this?
I'd like to avoid passing JSON via Pyo3 to python and THEN creating the model.
Use case:
I am moving bounding box processing logic in my library Docprompt into Rust. Documents can have tens of thousands of bounding boxes, so small overhead becomes an issue.
Thank you for the help!
The text was updated successfully, but these errors were encountered: