Under the Hood:
Do You Actually Need to Look?

A Whistle-Stop Refresher of CPython Internals - then the bigger conversation of comparing understanding v abstraction

15 May 2026
Python Leadership Roundtable
Alex Hatfield

The Ingredients of a Running Program:

📄

Your Source Code

+
🐍

The Python Runtime

Compilation Phase

1
Tokenizer
Chops source text into pieces
2
Parser
Builds an Abstract Syntax Tree (AST) from those pieces
3
AST Optimizer
Quick wins before compiling
4
Compiler
Turns the tree into simple instructions
5
.pyc Cache
Caches bytecode to disk
Source Code
x = 40 + 2 + y
→
Tokens
NAME 'x' OP '=' NUMBER '40' OP '+' NUMBER '2' OP '+' NAME 'y'
→
AST
assign ┌───┴────┐ variable bin op name: x op: + ┌───┴───┐ bin op variable op: + name: y ┌─┴─┐ 40 2
→
Optimised AST
assign ┌───┴────┐ variable bin op name: x op: + ┌───┴───┐ const variable 42 name: y
→
Bytecode
LOAD_CONST 42 LOAD_NAME 'y' BINARY_ADD STORE_NAME 'x' RETURN_CONST None

Execution Phase

6
Eval Loop
Reads and runs each instruction
7
Handlers
Ready-made routines, one per instruction
8
Frame Stack
One frame per function call, stacked up
9
Runtime Infrastructure
E.g. Python Objects, Memory Management, GIL
Bytecode In
LOAD_CONST 42 LOAD_NAME 'y' BINARY_ADD STORE_NAME 'x'
→
Eval Loop + Handlers (value stack)
LOAD_CONST 42 → stack: [42] LOAD_NAME 'y' → stack: [42, y] BINARY_ADD → stack: [42+y] STORE_NAME 'x' → stack: [] x = result

So... Did We Need to Know Any of That?

Joel Spolsky’s Law: all non-trivial abstractions leak. The question is when.

Discussion Starters

  • Has a leaky abstraction ever cost you? Has deep knowledge of something ever saved you?
  • What tools is it worth understanding better and what do we? LLMs, DBs, OSs, networking, cryptography...?
  • Are there some good rules of thumb for when to understand something and when to not?
  • How deep does one go - is it worth learning about the spin of the electrons in the CPU?