Master the fundamental concepts of cpython internals through this focused micro-challenge.
A Python function call crosses several C layers before your bytecode runs. Understanding \`PyObject_Call\`, frame setup, and the eval loop explains stack traces, profiling, and debugger breakpoints.
Rough path from \`f()\` to execution:
Each frame holds:
For example, calling \`add(2, 3)\` pushes arguments onto the new frame's stack, runs \`LOAD_FAST\`/\`BINARY_ADD\`, then returns via \`RETURN_VALUE\`.
Frame objects are among the hottest allocations in CPython. The interpreter caches empty frames and reuses them where possible. Watch `PyFrame_New` in profiles when optimizing call-heavy Python code.
This exercise asks you to document the CPython call path from Python source to \`ceval.c\`. You will trace frame creation, argument binding, and return so you can read real interpreter source with context.
You will use the same mental model here when reading production interpreter source later in the track. Sketch one concrete input on paper, predict the outcome, then confirm with code. That discipline catches logic errors early and makes debugging far faster when you extend the implementation in follow-on tasks.
Write a C program documenting the Python function call path.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github