-
Notifications
You must be signed in to change notification settings - Fork 0
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
Optimize DTOs json serialization #3
Comments
The main reason is that pydantic separately handles each value from nested collections. In this case, we have significant overhead due to the field "coordinates" of the "Vector" model. In this field, pydandic processes each int inside the list field. To solve this problem, you can write your own dict converter. For example, this mixin adds custom dict convertation to "Vector" model:
|
With such a trick we get:
|
test_perf_serialize run shows that
VektonnBaseModel.json()
is a huge bottleneck:The text was updated successfully, but these errors were encountered: