If you want to follow along in the Python source code, the relevant file is https://github.com/python/cpython/blob/master/Python/ceval.c. 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:
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.
1 comment
[ 2.7 ms ] story [ 9.5 ms ] thread