Exploring Python

In a first series of posts I would like to explore how python works behind the scenes. I am going to re build some parts of Python in Python itself. My aim is not to reproduce PyPy, a project that is implementing a production grade Python interpreter in Python. Rather I think that by rewriting – probably simplified – parts of the interpreter, I can understand them better.

There are two main advantages of using Python for implementing parts of Python. One is that I am using a language that I am familiar with and like to program in. The second but very important advantage is that i can use Python to do all the stuff I have not (yet) rewritten. As we will see Python exposes a lot of its internals readily accessible from within Python programs.

These are the major parts of the Python interpreter.

Components of the Python Interpreter

  1. A  compiler which produces bytecode, constant objects, lists of variable names and more from Python source code.
  2. An object model and built-in types, modules and functions.
  3. The interpreter itself, also known as a virtual machine, executing the bytecode and thereby modifying objects.

In my next posts I am going to write the third part, the virtual machine. The aim is to get it to run simple Python programs, and to understand how a virtual machine can be built.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: