TypeCheck vs IsInstance in C API

K

Kirk McDonald

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

http://docs.python.org/api/object.html

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_IsInstance:

int PyObject_IsInstance(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_TypeCheck:

int PyObject_TypeCheck(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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top