From 090decc97c016da4499ed78d15f010a2f396d27c Mon Sep 17 00:00:00 2001 From: Itamar Ostricher Date: Tue, 2 Nov 2021 13:37:36 -0700 Subject: [PATCH] PyType_IsSubtype: Return early for identical type objects --- Objects/typeobject.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 18bea476ea9f25..6b0621fbe155fb 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1547,6 +1547,10 @@ PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b) { PyObject *mro; + if (a == b) { + return 1; + } + mro = a->tp_mro; if (mro != NULL) { /* Deal with multiple inheritance without recursion