Runtime and Internals
How Python runs your code: memory, garbage collection, bytecode, the interpreter, the GIL and alternative implementations.
This is an overview — pick a sub-topic below.
Sub-topics (10)
Memory Management
Every value is a heap object; names are references, and memory is reclaimed automatically.
Reference Counting
Each object counts how many references point to it and is freed when the count reaches zero.
Garbage Collection
The gc module finds and frees groups of objects that reference each other (cycles).
Python Bytecode
CPython compiles source to bytecode instructions that its virtual machine executes; dis shows them.
The Python Interpreter
The program that runs Python code: python file.py, the interactive REPL, or python -m module.
The Global Interpreter Lock
In standard CPython only one thread executes Python bytecode at a time — threads help I/O, not CPU-bound work.
CPython
The reference implementation of Python, written in C — what you get from python.org.
PyPy
A Python implementation with a just-in-time compiler — often several times faster for pure-Python code.
Jython
Python running on the Java Virtual Machine, able to use Java classes directly.
IronPython
Python for .NET, with direct access to .NET libraries.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.