assert isinstance(module, ModuleType), '"{}" not a module.'.format(module)
if isinstance(getattr(module, '__loader__', None), ExtensionFileLoader):
    return True
In Python how can one tell if a module comes from a C extension?