Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用 Python C-API 检查 PyObject* 是否指向 numpy.uint8 等类型?
(请注意,我想检查 PyObject* 是否指向 numpy.uint8 类型,而不是它是否指向 numpy.uint8 类型的实例。)
您可以使用PyType_IsSubtype(child, parent)来查看子类型是否继承了父类型,但它操作的是PyTypeObject*,而不是PyObject*。
PyType_IsSubtype(child, parent)
PyTypeObject*
PyObject*