
When I decided to study it, I felt the same as Naruto learning the Rasengan: It was difficult to learn: Naruto took 3 years to learn; and I took 10 😂, since I firstly heard the words “interpreted”/“compiled” language when I was learning R.
Python, itself is an interpreted language, and there are many nuances that I want to discuss.
Let’s start by defining what is a programming language.
1 Programming language
A programming language can be defined by two main pillars:
- Specification (Rules):
- Syntax: how the code is written; some languages may be more verbose than others. For example, in
Cyou need to define the type of each variable and finish the line with;. WhereasPythondoes not require it, butindentationis obligatory for your code to run. - Semantics: It defines basic operations, such as, the operator
+, does what we think it does: add two values together (in case offloats/ints) or concatenate twolistsin Python. - Data Types & Core concepts: In
Python, we havedict, but we do not havedataframes;Ris the opposite.
- Syntax: how the code is written; some languages may be more verbose than others. For example, in
- Implementation:
- Machines do not understand
source code, only binary machine code (0s and 1s). So, for every programming language, a tool is necessary that translates the source code into binary code that can be:- Compiler: It will translate upfront the entire source code into a standalone binary executable. It is a characteristic of
C,RustandGoprogramming languages; - Interpreter: It will translate the source code into binary code at the runtime line by line. This is the primary implementation strategy for
Python,JavaScriptandR.
- Compiler: It will translate upfront the entire source code into a standalone binary executable. It is a characteristic of
- Machines do not understand
2 Python’s implementation
What makes a programming language interpreted or compiled is its implementation. Python has different implementations, such as:
NuitkaandCythonmake the Python a compiled language, so, all machine code is known ahead of time.PyPyusesJIT (Just-In-Time)compilation: it takes the Python source file, converts it to bytecode1, and directly compiles it into machine code during the runtime (not ahead of time). It is a just-in-time compiler, rather than an ahead-of-time compiler.CPython, the official implementation, first compiles the Python source code tobytecode2. Then the Python Virtual Machine (PVM) - itself a program in C - reads thatbytecodeand hands each instruction off to an already-existing C function inside the interpreter that carries it out. That’s why Python is known as an “interpreted language”.
Bytecodeplays a vital role here: Python caches the first time a module is imported, saving it as a.pycfile so it does not need to be recompiled on every subsequent import.- It never translates
Pythoncode intomachine codedirectly; instead, the PVM executes the bytecode by invoking the corresponding pre-compiled C function for each instruction.
Finally, what makes a language interpreted or compiled is the implementation, not the language itself.
This picture describes the whole process of executing Python source code:

There is more! Keep reading Part 2!
Happy Coding!
Footnotes
bytecode is an intermediate low-level code that can be read and interpreted by a machine, being originated by a source code.↩︎
you can inspect the bytecode of any Python function by calling
dis.dis(<your_function>), see is python a dynamic language.↩︎