Add class-level caching of whether __getattribute__ exists
This is not quite the same as checking whether tp_getattro has been updated, since setting a __getattr__ will change tp_getattro. Usually this isn't that important since we will still need to do some special getattr handling, but in a couple specific cases we can optimize based on it. In particular, this commit optimizes calls to isinstance(inst, cls) on instances which have a __getattr__ set: in the common case (no __getattribute__, no custom __class__) we can know that the __getattr__ will not get called and we can stay on the isinstance fastpath.
Showing
Please register or sign in to comment