When checking the types of parameters to an operator method, be aware that the Python functions isinstance() and issubclass()
can be fooled by objects that redefine their __class__ attribute. This
is all right in Python, but it's not acceptable for something that
needs to access the C attributes of an object. It's better (as well as
faster) to use the PyObject_IsInstance() and PyObject_IsSubclass() C API functions. You can gain access to them with the following declarations:
cdef extern from "Python.h": int PyObject_IsInstance(object, object) int PyObject_IsSubclass(object, object)