A runtime-first engineering manual · Ahmed Sedik
Predict Python.
Don't memorize its surprises.
Build one connected model from the machine to the object model, concurrency, and memory—then use it to debug safer code and answer the interview questions that expose shallow knowledge.
First edition · CPython 3.12–3.14 checked

Try the method
What prints on the second line?
Read the code before opening the answer. The book starts with observable behavior, then replaces the tempting wrong model with the shortest correct one.
def remember(item, bucket=[]):
bucket.append(item)
return bucket
print(remember("metal"))
print(remember("mind"))Reveal the output and mechanism
['metal']
['metal', 'mind']The model: a default argument is evaluated when Python executes the def statement—not each time the function is called. Both calls therefore mutate the same list.
Python language guarantee
In an interview, do more than name the “mutable default” trap. Explain when the object is created, why it is reused, and when persistent state might be intentional.
One connected mental model
From silicon to source-level decisions.
Python feels full of exceptions when the layers are learned in isolation. The book follows the causal chain so each layer explains the next.
- 01MachineCPU, memory, and cost
- 02BytecodeCompilation and evaluation
- 03ObjectsNames, identity, and mutation
- 04ProtocolsClasses, lookup, and iteration
- 05ConcurrencyAsync, threads, and the GIL
- 06MemoryGC, free threading, and the JIT
The chapter rhythm
Explanation without hand-waving.
Every chapter completes the same learning arc. You see the behavior, build the mechanism, mark the boundary, and use the model under pressure.
“Simplify the sentence, not the idea.”
- 01Predict
Start with a small puzzle or production incident.
- 02Explain
Replace the wrong intuition with the exact mechanism.
- 03Bound
Separate Python promises from CPython details.
- 04Apply
Make a safer production or debugging decision.
- 05Defend
Answer the deceptive interview follow-up.
Know what you can rely on
Not every true observation is a promise.
Safe contractPython language guarantee
Explain, don't dependCPython implementation detail
Check the runtimeVersion-dependent
Never design around itOptimization — do not rely on it
In every chapter
The Interview Room
These are not trivia dumps. Each ladder tests whether you can move from output to mechanism to engineering judgment.
Practice with the code- Screen
State the key distinction clearly.
- Predict
Commit to the exact output.
- Explain
Walk through the runtime mechanism.
- Decide
Choose the safer production design.
- Bound
Say what changes across runtimes or versions.
Reader fit
For engineers who already use Python—and want to reason beneath it.
This book is for you if…
- You write working Python but want to explain why it behaves as it does.
- You debug object-model, concurrency, memory, or performance problems.
- You are preparing for interviews that probe past syntax.
- You want plain language without losing technical precision.
It is not designed as…
- A first introduction to Python syntax
- A catalog of shortcuts to memorize
- A promise that every CPython detail is portable
Start before the book arrives
Run the examples. Make a prediction. Check your model.
The public companion repository lets you browse each example, run the verification script, or download the full collection.
Open the free repository