Is Python a Compiled or Interpreted Language? Uncover the Truth
This article explores whether Python is a compiled or interpreted language by examining its compilation stages, error‑message generation, differences across Python versions, and the broader distinction between static and dynamic language features, ultimately showing that Python combines both compilation and interpretation.
Many people assume Python is purely interpreted, but it actually undergoes compilation steps before execution.
Technical Background
The author is creating a course on reading error messages for C, Python, and Java, noting that errors appear at different stages: some are reported during compilation, others at runtime.
Compilation Stages in C
Preprocessing
Lexical analysis
Syntax analysis
Semantic analysis
Linking
Python lacks preprocessing and linking stages, so those topics are omitted.
Python Error Message Game
A small program with multiple errors is used to see which error is reported first in Python 3.12.
1 / 0
print() = None
if False
ñ = "helloThe first error reported is the syntax error on the last line (unterminated string), showing that Python scans the whole file before execution.
Subsequent Rounds
After fixing the first error, the next reported error is the assignment to a function call:
File "/private/tmp/round_2.py", line 2
print() = None
^^^^^^^
SyntaxError: cannot assign to function call here. Maybe you meant '==' instead of '='?Further rounds demonstrate that syntax errors are detected before runtime errors like ZeroDivisionError.
Python Virtual Machine
Python source is compiled to bytecode, which the Python Virtual Machine (PVM) executes, making Python a “compiled‑interpreted” language.
Older Python versions had an extra stage checking valid assignment targets, causing differences in error order between Python 3.8 and Python 3.12.
Broader Perspective
The article argues that the compile vs interpret dichotomy is misleading; languages have static and dynamic properties, and Python leans toward dynamic features.
It also notes that many “interpreted” languages like JavaScript are JIT‑compiled, and that REPLs exist for compiled languages such as Java (jshell) and Haskell (GHC).
Conclusion: Whether Python is compiled or interpreted is less important than understanding which properties are determined statically versus dynamically.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
21CTO
21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
