Skip to content
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

Cythonize (de)serialization methods and enable errors customization #235

Merged
merged 15 commits into from
Nov 3, 2021

Conversation

wyfo
Copy link
Owner

@wyfo wyfo commented Oct 31, 2021

Closures have been converted into classes with one method. They have been regrouped in modules called methods.py. Only methods modules are cythonized.

Cythonization is made by generating a pyx file from the Python file. This approach doesn't require much adaptation to the Python code. Also, it allows optimizations like dynamic dispatch conversion to switch (Python code would have been dirty to with a lot of if-chains).

As constraints validation has been completely refactored to be cythonized too, error customization has been added at the same time as it was simpler.

Closures have been converted into classes with one method. They have been regrouped in modules called methods.py. Only methods modules are cythonized.

Cythonization is made by generating a pyx file from the Python file. This approach doesn't require much adaptation to the Python code. Also, it allows optimizations like dynamic dispatch conversion to switch (Python code would have been dirty to with a lot of if-chains).

As constraints validation has been completely refactored to be cythonized too, error customization has been added at the same time as it was simpler.
@wyfo
Copy link
Owner Author

wyfo commented Oct 31, 2021

Performances are greatly improved. Pydantic benchmark shows about x2.7 for serialization and x1.7 for deserialization.

@wyfo wyfo added this to the v0.17 milestone Nov 2, 2021
@wyfo wyfo merged commit fccfbe3 into master Nov 3, 2021
@wyfo wyfo deleted the optimization branch November 3, 2021 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance optimization Constraints error messages customization
1 participant