if isinstance(getattr(module, '__loader__', None), ExtensionFileLoader):
    return True
module_filename = inspect.getfile(module)
module_filetype = os.path.splitext(module_filename)[1]
In Python how can one tell if a module comes from a C extension?