python / python-orientation
10 mins
Python Level 0: Interpreter & Object References
Why This Matters: Python executes through an interpreted bytecode runtime where variable names are dynamic reference tags bound to heap objects.
## The Python Dynamic Runtime Model Python is an **interpreted, dynamically-typed language** created by Guido van Rossum. ### Key Mental Model Differences from C - **Object References**: Variables don't hold raw memory slots; they store reference tags pointing to heap objects. - **Dynamic Typing**: Variable types are determined at runtime by the object they point to. - **Automatic Garbage Collection**: Reference counting automatically reclaims unreferenced objects.
MENTAL MODEL & MEMORY LAYOUT
PYTHON OBJECT REFERENCE MODEL: Variable Name 'x' ──► [ Integer Object: 42 ] (Ref Count: 1) Variable Name 'y' ──► [ Integer Object: 42 ] (Shared Reference)
COMMON PITFALLS TO AVOID
- Expecting variable types to be static (reassigning integer to string is allowed in Python).
- Forgetting that code blocks are defined by whitespace indentation rather than braces `{}`.
Dynamic Reference Binding
x = 42 # x references int object x = "GrowCode" # x re-bound to str object! print(type(x)) # Outputs <class 'str'>
Demonstrates Python variable names re-binding to different heap object types over time.
CONCEPT MASTERY CHECKPOINT
In Python, what is a variable name?
NEXT RECOMMENDED LESSON
Python Level 1: Variables & Strings
Challenge: Write Python code to print 'Hello GrowCode Python!'.