During my last CPython sprint, I started to contribute to the CPython code and I wanted to understand the beast.
In this case, there is only one solution, trace the code from the beginning. From the command line to the interpreter, we will take part to an adventure
The idea behind is just to show how CPython works for a new contributor to CPython.
From the command line, we will learn that Python is a library and that we can embed it in a C project. In fact we will see the Py_Main function to the ceval.c file of the interpreter.
But there is no magic in the CPython code, we will travel in the lexer and the parser of CPython, and why not, by the AST for one Python expression.
After the AST, we will visit the Compiler and the Bytecodes for the interpreter. Of course, we will learn there is the peepholer where some basic instructions are optimised by the this component.
And of course, the interpreter, this virtual machine is really interesting for the newbiew, because it’s a big stack where the bytecodes are executed one by one on the stack and the ceval.c file.