Q1: What is Python and how does its execution flow differ from compiled languages?
Python is a high-level, dynamically typed, interpreted programming language. Source code (.py) is first compiled into intermediate bytecode (.pyc). The Python Virtual Machine (PVM) then interprets this bytecode line-by-line into machine code at runtime.
Inspecting Python Bytecode
import dis
def add(a, b):
return a + b
dis.dis(add) # Disassembles bytecode instructions💡 The dis module exposes the raw PVM bytecode instructions produced for Python functions.
Key Takeaways
- Compilation to Bytecode (
.pyc) occurs automatically prior to PVM interpretation. - Dynamic typing resolves variable types at runtime rather than compile time.
Knowledge Check
What component in Python directly executes bytecode (.pyc) files?