TypeCheck vs IsInstance in C API

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kirk McDonald

    #1

    TypeCheck vs IsInstance in C API

    I'm examining the C API, and I have a question.



    There are two functions that appear to do nearly same thing, and I just
    want to be certain I'm not missing something. First is PyObject_IsInst ance:

    int PyObject_IsInst ance(PyObject *inst, PyObject *cls);
    Returns 1 if inst is an instance of the class cls or a subclass of cls,
    or 0 if not...

    Second is PyObject_TypeCh eck:

    int PyObject_TypeCh eck(PyObject *o, PyTypeObject *type);
    Return true if the object o is of type type or a subtype of type...

    Now, I can see that IsInstance can take a tuple as the second argument
    and check the type of the first argument against every item in the
    tuple. I also see that TypeCheck was added in version 2.2. Why was it
    added? Its functionality already seems covered by IsInstance. Is it a
    new-style vs. old-style class thing?

    -Kirk McDonald
Working...