Given a class object in Python, how can I determine if the class was defined in an extension module (e.g. c, c++, cython), as opposed to being defined in standard python?
inspect.isbuiltin returns True for functions defined in an extension module, and False for functions defined in python, but it unfortunately does not have the same behavior for classes -- it returns False for both kinds of classes.
(The larger goal here is that we've got a system that generates a command line API for a set of classes based on parsing the docstring and signature of their __init__ functions. This system fails for classes defined in cython because inspect.getargspec doesn't work correctly on these classes, so I'm trying to figure out a workaround)
"This system fails for classes defined in cython because X"
Doesn't this mean that the answer you're looking for is X?
To know if a class is of the kind that crashes some function, like when you do inspect.getargspec(X.__init__), then just do inspect.getargspec(X.__init__) in a try: except block.
Check if class object is defined in extension module