What happens on the computer when you run print(“Hello world”)? This talk attempts to dissect how Python code gets translated for execution. While many programmers can live without interacting with compiler internals, a stronger understanding of CPython can help make us better programmers.
Python is a widely-used programming language thanks to its simple code syntax, but this convenience is brought by the hard work of the compiler. Among the many implementations (like PyPy and JPython), we will look at the most widely used CPython implementation. The talk will look at the compilation steps, and examine how the resulting bytecode will be executed in the Python virtual machine. Before a simple string is displayed on a terminal, CPython processes code performs complicated tasks from lexical analysis, parsing, compilation, and to evaluation loop. Even executing a simple program like print(“Hello world”) requires this laborious process performed instantly on the computer. By understanding the execution pipeline, we can identify execution bottlenecks to improve code performance.