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

speedup __instancecheck__ check on BaseModel when they fail #4081

Merged
merged 3 commits into from May 17, 2022

Conversation

samuelcolvin
Copy link
Member

@samuelcolvin samuelcolvin commented May 16, 2022

Change Summary

abc __isinstancecheck__ can be very slow and eat a lot of memory, this seems to be particularly bad in the check returns False.

We do this check a lot when generating schemas, often for types we can easily check are not Models.

Related issue number

FIx possibly for #3829, avoid performance depredation and memory growth in abc __isinstancecheck__, see python/cpython#92810

Checklist

  • Unit tests for the changes exist
  • Tests pass on CI and coverage remains at 100%
  • changes/<pull request or issue id>-<github username>.md file added describing change

@samuelcolvin samuelcolvin marked this pull request as ready for review May 16, 2022 10:29
@samuelcolvin samuelcolvin merged commit abea823 into master May 17, 2022
@samuelcolvin samuelcolvin deleted the BaseModel-instancecheck branch May 17, 2022 13:13
@samuelcolvin samuelcolvin mentioned this pull request May 17, 2022
11 tasks
ntaylorwss pushed a commit to nicejobinc/pydantic that referenced this pull request Jun 24, 2022
…#4081)

* speedup __instancecheck__ check on BaseModel when they fail

* add change description

* linting
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.

None yet

1 participant