Implementing PyMyType_Check methods with the Python C API?

All types supported by Python have a validation method (i.e. PyList_Check) that allows you to check if an arbitrary is a PyObject*specific type.

How can I implement this for my own types? I did not find anything good on the Internet for this, although it seems like a pretty normal thing that I want to do.

Besides, maybe I'm just looking terribly at the big source trees, but I can’t find the implementation PyList_Checkor any of its companions in the Python source (2.5) for life .

+3
source share
2 answers

, ...

#define PyMyType_Check(op) \
    PyObject_TypeCheck(op, &PyMyType_Type)
0

Source: https://habr.com/ru/post/1744831/


All Articles