Learning Python: Chapter 2

Devcult - 6G and Satellites
1 min readApr 25, 2019

How Python Runs Programs

When the Python package is installed on the machine, it generates a number of components — minimally an interpreter and support library. The python code your write is always run by this interpreter.

An interpreter is a kind of program that executes other programs.

The python interpreter is a program that runs the programs that you write.

The standard execution model

When a program is executed,

  1. Python first compiles the source code into a format known an byte code which is platform independent. This is performed to speed execution. If the python process has write access on your machine, it will store the byte code in files that end with a .pyc extension(compiled .py code). Usually, .pyc byte code files will be saved in a subdirectory named pycache.
  2. This byte code is then shipped off for execution to the Python Virtual Machine(PVM). PVM(In C and C++, CPU executes the machine code) is kind of a big code loop that iterates through your byte code instructions, one by on e to carry out their operations.

All these components together form the python interpreter.

There are several variations for this standard execution model(by replacing byte code and VMs or by adding tools and Just In Time Compilers)

So there is no pre-compile and link steps in program execution. This makes for a much more rapid development cycle.

Python language has several implementations. PyPy is just one of them(It targets speed).

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Devcult - 6G and Satellites
Devcult - 6G and Satellites

No responses yet

Write a response