summaryrefslogtreecommitdiffstats
path: root/Include/object.h
diff options
context:
space:
mode:
Diffstat (limited to 'Include/object.h')
-rw-r--r--Include/object.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/Include/object.h b/Include/object.h
index 0c5fa42..40e52e3 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -357,7 +357,8 @@ PyAPI_DATA(PyTypeObject) PyType_Type; /* built-in 'type' */
PyAPI_DATA(PyTypeObject) PyBaseObject_Type; /* built-in 'object' */
PyAPI_DATA(PyTypeObject) PySuper_Type; /* built-in 'super' */
-#define PyType_Check(op) PyObject_TypeCheck(op, &PyType_Type)
+#define PyType_Check(op) \
+ PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_TYPE_SUBCLASS)
#define PyType_CheckExact(op) ((op)->ob_type == &PyType_Type)
PyAPI_FUNC(int) PyType_Ready(PyTypeObject *);
@@ -469,11 +470,23 @@ given type object has a specified feature.
#define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION 0
#endif
+/* These flags are used to determine if a type is a subclass. */
+#define Py_TPFLAGS_INT_SUBCLASS (1L<<23)
+#define Py_TPFLAGS_LONG_SUBCLASS (1L<<24)
+#define Py_TPFLAGS_LIST_SUBCLASS (1L<<25)
+#define Py_TPFLAGS_TUPLE_SUBCLASS (1L<<26)
+#define Py_TPFLAGS_STRING_SUBCLASS (1L<<27)
+#define Py_TPFLAGS_UNICODE_SUBCLASS (1L<<28)
+#define Py_TPFLAGS_DICT_SUBCLASS (1L<<29)
+#define Py_TPFLAGS_BASE_EXC_SUBCLASS (1L<<30)
+#define Py_TPFLAGS_TYPE_SUBCLASS (1L<<31)
+
#define Py_TPFLAGS_DEFAULT ( \
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | \
0)
#define PyType_HasFeature(t,f) (((t)->tp_flags & (f)) != 0)
+#define PyType_FastSubclass(t,f) PyType_HasFeature(t,f)
/*