chris <[EMAIL PROTECTED]> writes:

> I want to check the type of an object, right now I am doing
> strcmp( object->ob_type->tp_name, "MyClass")
>
> Which seems slow, is there a way I can find the pointer to the
> global PyTypeObject for MyClass, and then just call
> PyObject_TypeCheck?

Simply get the PyObject that corresponds to MyClass using
PyObject_GetAttr on the module (or in some other way).  If MyClass is
a new-style class, you can cast it to PyTypeObject and compare that to
object->ob_type.

For questions about the C API, see the capi-sig,
http://mail.python.org/mailman/listinfo/capi-sig
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to