TypeCheck vs IsInstance in C API

Discussion in 'Python' started by Kirk McDonald, May 30, 2006.

  1. 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
    Kirk McDonald, May 30, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joona I Palaste

    Re: isInstance problem

    Joona I Palaste, Jul 1, 2003, in forum: Java
    Replies:
    4
    Views:
    1,026
    George W. Cherry
    Jul 2, 2003
  2. Ben Jessel

    Re: isInstance problem

    Ben Jessel, Jul 10, 2003, in forum: Java
    Replies:
    0
    Views:
    395
    Ben Jessel
    Jul 10, 2003
  3. Michal Vitecek

    isinstance() bug

    Michal Vitecek, Jan 28, 2004, in forum: Python
    Replies:
    6
    Views:
    441
    Sidharth Kuruvila
    Jan 28, 2004
  4. Gregory Petrosyan

    Optional typecheck

    Gregory Petrosyan, Jan 7, 2006, in forum: Python
    Replies:
    2
    Views:
    332
    Gregory Petrosyan
    Jan 9, 2006
  5. Collin Winter

    [ANNOUNCE]: typecheck 0.3.5 released

    Collin Winter, May 28, 2006, in forum: Python
    Replies:
    0
    Views:
    260
    Collin Winter
    May 28, 2006
Loading...

Share This Page