Open
Description
As of #492 ModelValidator
is checking if the input is an instance of BaseModel
before doing anything else.
Because BaseModel
is an abc, the isinstance
rust call is eventually calling the python __instancecheck__
method on BaseModel
's metatype.
isinstance checks have significant performance problems, see pydantic/pydantic#3829 and python/cpython#92810.
We should look at removing this check by implementing a faster isinstance
check but just looking at the type, and the type's tp_base
(or maybe tb_bases
) - this would effectively lead to a fast_isinstance
method.