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

Cache pydantic model fields for faster decoding #132

Merged
merged 1 commit into from
May 10, 2023

Conversation

mjpieters
Copy link
Collaborator

In timeit tests, 10.000 calls to ModelField() could take up to half a second on my Macbook Pro M1, depending on the type annotation used. Given that the method is called for every cache hit, this can really add up. The number of different return types for endpoints is very much finite however, so caching is a definite win here.

@mjpieters mjpieters marked this pull request as ready for review May 9, 2023 12:43
In `timeit` tests, 10.000 calls to `ModelField()` could take up to half
a second on my Macbook Pro M1, depending on the type annotation used.
Given that the method is called for every cache hit, this can really add
up. The number of different return types for endpoints is very much
finite however, so caching is a definite win here.
@mjpieters mjpieters force-pushed the cache_pydantic_fields branch from 6382ee9 to 7c30402 Compare May 9, 2023 16:25
@long2ice
Copy link
Owner

Thanks!

@long2ice long2ice merged commit 5f2fcf3 into long2ice:main May 10, 2023
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.

2 participants