Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.2k
Override__subclasscheck__
onModelMetaclass
to avoid memory leak and performance issues#11116
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
… and performance issuesWe avoid relying on `ABCMeta.__subclasscheck__` unless we're pretty sure.Note that this was wrongly addressed as `__instancecheck__` was implementedinstead of `__subclasscheck__`. However, it is not clear if implementing`__instancecheck__` fixed existing issues as well, so it is left as is.Also changed the checked attribute to `__pydantic_decorators__`, asthis is one of the first attributes being set on the class, and itmight be that we change the way `__pydantic_validator__` is set inthe future (e.g. when `defer_build` is set, and if we don't implementmock validators anymore).
Deploying pydantic-docs with |
Latest commit: | 1922dfe |
Status: | ✅ Deploy successful! |
Preview URL: | https://41a7f040.pydantic-docs.pages.dev |
Branch Preview URL: | https://subclasscheck.pydantic-docs.pages.dev |
CodSpeed Performance ReportMerging#11116 willnot alter performanceComparing Summary
|
Coverage reportClick to see where and how coverage changed
This report was generated bypython-coverage-comment-action |
sydney-runkle left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Clean. Nice. Thanks! Could you add a test before we merge?
What kind of test are you looking for? We already have |
95c374d
intomainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
We avoid relying on
ABCMeta.__subclasscheck__
unless we're pretty sure. Note that this was wrongly addressed as__instancecheck__
was implemented instead of__subclasscheck__
. However, it is not clear if implementing__instancecheck__
fixed existing issues as well, so it is left as is.Also changed the checked attribute to
__pydantic_decorators__
, as this is one of the first attributes being set on the class, and it might be that we change the way__pydantic_validator__
is set in the future (e.g. whendefer_build
is set, and if we don't implement mock validators anymore).Fixes#11100.
Change Summary
Related issue number
Checklist