If you want to follow along in the Python source code, the relevant file is <a href="https://github.com/python/cpython/blob/master/Python/ceval.c" rel="nofollow">https://github.com/python/cpython/blob/master/Python/ceval.c</a>. The interpreter is a loop over a big switch statement on the byte codes. Most operations are pretty simple. For example, here is the implementation of the BINARY_MULTIPLY instruction:<p><pre><code> case TARGET(BINARY_MULTIPLY): {
PyObject *right = POP();
PyObject *left = TOP();
PyObject *res = PyNumber_Multiply(left, right);
Py_DECREF(left);
Py_DECREF(right);
SET_TOP(res);
if (res == NULL)
goto error;
DISPATCH();
}
</code></pre>
This corresponds to the article's description, but it also adds reference counting (the Py_DECREF operations) and error handling. The real work is inside the PyNumber_Multiply function, which must check the operand types and execute the appropriate operation.