We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Exploring our Python Interpreter

Formal Metadata

Title
Exploring our Python Interpreter
Title of Series
Part Number
32
Number of Parts
169
Author
License
CC Attribution - NonCommercial - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
Stephane Wirtel - Exploring our Python Interpreter During the last CPython sprints at PyCon US (Montreal), I started to contribute to the CPython project 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. ----- 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 * Overview of the structure of the project and the directories. * From the Py_Main function to the interpreter. * The used technics for the Lexer, Parser and the generation of the AST and of course of the Bytecodes. * We will see some bytecodes with the dis module. * How does VM works, it's a stack machine. * The interpreter and its main loop of the Virtual Machine. 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.