I tried to look around but I couldn't find anything clear about this topic.
Are built-in functions implemented in a module that is automatically imported every time Python is launched? In the case which is the module?
Or are built-in functions just embedded functions inside the Python interpreter?
For CPython, the built-in functions are (for the most part) implemented in the
bltinmodule.c
file.The exceptions are mostly the types; things like
str
anddict
andlist
have their own C files in theObjects
directory of the C source; these are listed as a table in thebltinmodule
source.Technically speaking, this is treated as a separate module object by the implementation, but one that is automatically searched when the current global namespace does not contain a name. So when you use
abs()
in your code, and there is noabs
object in the global namespace, the built-ins module is also searched for that name.It is also exposed as the
__builtin__
module (orbuiltins
in Python 3) so you can access the built-in names even if you shadowed any in your code. Like thesys
module, however, it is compiled into the Python binary, and is not available as a separate dynamically loaded file.