Interpreter & Thread state & Frame structures.

Benjamin musiccomposition at
Thu Jan 8 04:27:44 CET 2009

On Jan 7, 7:42 am, at wrote:
> Hi to all,
> there are some fields in the PyInterpreterState and PyThreadState
> obscures.
> PyInterpreterState:
>   1) Why there are the fields *next and *tstate_head?

When there are multiple interpreters active, they are kept in a linked
list. *next refers to the next interpreter state in the list.

> PyThreadState:
>   1) Why there is the field *next?

ditto for thread states

> An object PyFrameObject is a portion of code, with a state. But
> exactly? Contents of a method/function, or more simply any block
> indented of code? For example, this code:
>     def foo(s):
>         if s > 0:
>             return True
>         else:
>             return False
> how much frames are?

1 in this case.

Each, module, class, function (and method) have a code object which
corresponds to one frame when it is executed.

More information about the Python-list mailing list