Skip to content
dreamcode
dreamcode
Back to map
Python Internals · Lesson 34 of 44
+15 XP on finish
PYTHON EXPERT

Bytecode, GIL, and memory management

CPython compiles source code to bytecode (.pyc) executed by the virtual machine. Memory is managed via reference counting and a cyclic garbage collector, thread-locked by the Global Interpreter Lock.

How it reads
sys.getrefcount(...) returns references pointing to the object
CPython's GIL prevents multiple native threads from executing bytecodes at once
Cloud tip: Reference counting deletes objects immediately when count drops to 0; cycle GC handles self-referencing loops.
main.py
PYTHON
real Python, runs in your browser
CONSOLE
- run your code to see output -