In Python how can one tell if a module comes from a C extension?
问题 What is the correct or most robust way to tell from Python if an imported module comes from a C extension as opposed to a pure Python module? This is useful, for example, if a Python package has a module with both a pure Python implementation and a C implementation, and you want to be able to tell at runtime which one is being used. One idea is to examine the file extension of module.__file__ , but I'm not sure all the file extensions one should check for and if this approach is necessarily