The Python Language Reference, Release 3.9.5 Internal types A few types used internally by the interpreter are exposed to the user. Their definitions may change with future versions of the interpreter, but they are mentioned here for completeness. Code objects Code objects represent byte-compiled executable Python code, or bytecode . The difference be- tween a code object and a function object is that the function object contains an explicit reference to the function’s globals (the module in which it was defined), while a code object contains no context; also the default argument values are stored in the function object, not in the code object (because they repre- sent values calculated at run-time). Unlike function objects, code objects are immutable and contain no references (directly or indirectly) to mutable objects. Special read-only attributes: co_name gives the function name; co_argcount is the total num- ber of positional arguments (including positional-only arguments and arguments with default values); co_posonlyargcount is the number of positional-only arguments (including arguments with de- fault values); co_kwonlyargcount is the number of keyword-only arguments (including arguments with default values); co_nlocals is the number of local variables used by the function (including arguments); co_varnames is a tuple containing the names of the local variables (starting with the ar- gument names); co_cellvars is a tuple containing the names of local variables that are referenced by nested functions;$_{co_freevars}$ is a tuple containing the names of free variables;$_{co_code}$is a string representing the sequence of bytecode instructions;$_{co_consts}$ is a tuple containing the literals used by the bytecode; $_{co_names}$is a tuple containing the names used by the bytecode; co_filename is the filename from which the code was compiled; co_firstlineno is the first line number of the function; co_lnotab is a string encoding the mapping from bytecode offsets to line numbers (for de- tails see the source code of the interpreter);$_{co_stacksize}$is the required stack size;$_{co_flags}$ is an integer encoding a number of flags for the interpreter. The following flag bits are defined for$_{co_flags}$ : bit$_{0x04}$ is set if the function uses the$_{*arguments}$ syntax to accept an arbitrary number of positional arguments; bit$_{0x08}$ is set if the function uses the **keywords syntax to accept arbitrary keyword arguments; bit$_{0x20}$ is set if the function is a gener- ator. Future feature declarations ($_{from __future__ import division}$ ) also use bits in$_{co_flags}$ to indicate whether a code object was compiled with a particular feature enabled: bit$_{0x2000}$ is set if the function was compiled with future division enabled; bits$_{0x10}$ and$_{0x1000}$ were used in earlier versions of Python. Other bits in$_{co_flags}$ are reserved for internal use. If a code object represents a function, the first item in$_{co_consts}$ is the documentation string of the function, or$_{None}$ if undefined. Special read-only attributes: f_back is to the previous stack frame (towards the caller), or$_{None}$ if this is the bottom stack frame;$_{f_code}$is the code object being executed in this frame;$_{f_locals}$ is the dictionary used to look up local variables;$_{f_globals}$ is used for global variables;$_{f_builtins}$ is used for built-in (intrinsic) names;$_{f_lasti}$gives the precise instruction (this is an index into the bytecode string of the code object). Accessing $_{f_code}$raises an auditing event object.__getattr__ with arguments $_{obj}$and "f_code" . Special writable attributes: f_trace , if not$_{None}$ , is a function called for various events during code execution (this is used by the debugger). Normally an event is triggered for each new source line - this can be disabled by setting$_{f_trace_lines}$ to$_{False}$. Implementations may allow per-opcode events to be requested by setting$_{f_trace_opcodes}$ to$_{True}$. Note that this may lead to undefined interpreter behaviour if exceptions raised by the trace function escape to the function being traced. f_lineno is the current line number of the frame — writing to this from within a trace function jumps to the given line (only for the bottom-most frame). A debugger can implement a Jump command (aka Set Next Statement) by writing to f_lineno. Frame objects support one method: Frame objects Frame objects represent execution frames. They may occur in traceback objects (see below), and are also passed to registered trace functions. Chapter 3. Data model 24