What is the difference between a Python module, a built-in module, a standard module, and a frozen module?
These terms come from the official documentation itself.
Python module and built-in module are mentioned in the loader documentation:
Loaders must satisfy the following requirements:
- If the module is a Python module (as opposed to a built-in module or a dynamically loaded extension), the loader should execute the module’s code in the module’s global name space (module.__dict__).
Standard module is referenced in the Top-Level Components documentation:
all built-in and standard modules are available
Frozen module has its own importer, which is described as
An importer for frozen modules
Despite mention in official documentation and core code, there is no definitive definition for Python module, builtin-module, standard module, or frozen module in the glossary, index (B, F, M, P, or S), or (apparently) elsewhere.
Definition: Builtin-module
Here is the best definition I could come up with for builtin-module:
A builtin-module is an extension module (i.e. written in C, Java, .NET, etc.) which is listed in the
sys.builtin_module_names
attribute. Note that this list may vary with the Python interpreter (i.e. a builtin-module for Cython may not be a builtin module for IronPython, etc.).
I pieced this definition together from the following sources:
The documentation for the standard library states,
The library contains built-in modules (written in C)
The importlib.machinery.BuiltinImporter
documentation states,
All known built-in modules are listed in
sys.builtin_module_names
.
The sys.builtin_module_names
attribute documentation in turn states,
the names of all modules that are compiled into this Python interpreter. (This information is not available in any other way)
Definition: frozen module*
The Python2.7 imp
documentation states,
A frozen module is a module written in Python whose compiled byte-code object is incorporated into a custom-built Python interpreter by Python’s freeze utility.
It's worth noting that this definition is not present in the Python3 docs. Whether this omission is an oversight is unclear. Reference is still made in the Python3 docs to frozen modules.
I have not had any luck finding resources that help define Python module or standard module.
* Thanks to @martineau for the reference