What is the process of compilation and linking in python?
The source code in python is saved as a .py file which is then compiled into a format known as byte code. Compilation is simply a translation step. Byte code is a lower level and platform independent machine code which represents your source code. After the compilation, the code is stored in .pyc files and is regenerated when the source is updated or when it is necessary to do so. This process is known as compilation.
The byte code in the .pyc file is then loaded into the python runtime and interpreted by a python virtual machine that reads each instruction in the .pyc file and executes whatever operation is needed. Linking is the final phase where all the functions are linked with their definitions as the linker knows where all these functions are implemented. This process is known as linking.