From https://docs.python.org/3/library/importlib.html
The purpose of the
importlib
package is two-fold.One is to provide the implementation of the
import
statement (and thus, by extension, the__import__()
function) in Python source code. This provides an implementation ofimport
which is portable to any Python interpreter. This also provides an implementation which is easier to comprehend than one implemented in a programming language other than Python.Two, the components to implement
import
are exposed in this package, making it easier for users to create their own custom objects (known generically as an importer) to participate in the import process.
Does it mean that both the import
statement and builtin.__import__()
function are by default implemented based on importlib.__import()
function?
But https://stackoverflow.com/a/44655619/156458 implies that
builtins.__import__
is not implemented based on importlib.__import__
by default.
https://docs.python.org/3/library/functions.html#import says that
buitlins.__import__
function is invoked by the import
statement. so if builtins.__import__
is not implemented based on importlib.__import__
by default, the import
statement is not implemented based on importlib.__import__
by default either.