Message292764
Currently the first lines in PyObject_IsSubClass are:
/* We know what type's __subclasscheck__ does. */
if (PyType_CheckExact(cls)) {
/* Quick test for an exact match */
if (derived == cls)
return 1;
return recursive_issubclass(derived, cls);
}
The if (derived == cls) runs only if PyType_CheckExact is True which doesn't hold for any classes with a custom metaclass. As a result, a check of the form issubclass(Sequence, Sequence) will take a slow path that invokes __subclasscheck__.
I'm not sure if this was placed inside there due to some wild edge-case, though. PyObject_IsInstance uses the same trick and does so outside the if (PyType_CheckExact(cls)) check.
I'll gladly submit a PR if this indeed needs fixing and not by design. |
|
Date |
User |
Action |
Args |
2017-05-02 14:30:45 | Jim Fasarakis-Hilliard | set | recipients:
+ Jim Fasarakis-Hilliard |
2017-05-02 14:30:45 | Jim Fasarakis-Hilliard | set | messageid: <1493735445.03.0.987403403044.issue30230@psf.upfronthosting.co.za> |
2017-05-02 14:30:44 | Jim Fasarakis-Hilliard | link | issue30230 messages |
2017-05-02 14:30:44 | Jim Fasarakis-Hilliard | create | |
|