Introduction to the Python Interpreter, Part 2: Code Objects

1 · Allison Kaptur · Nov. 16, 2013, 3:22 a.m.
[Edit: A significantly expanded version of this series appears as a chapter in The Architecture of Open Source Applications, volume 4, as A Python Interpreter Written in Python.] This is part of a series on the python interpreter. Part 1 here. When we left our heroes, they were examining a simple function object. Let’s now dive a level deeper, and look at this function’s code object. 1 2 3 4 5 6 7 8 >>> def foo(a): ... x = 3 ... return x + a ... >>> foo <function foo at 0x107ef7aa0> >>>...