[New-bugs-announce] [issue40941] Merge generator.gi_running and frame executing flag into single frame state

Mark Shannon report at bugs.python.org
Wed Jun 10 09:33:12 EDT 2020


New submission from Mark Shannon <mark at hotpy.org>:

Generators have a "gi_running" attribute (coroutines have an equivalent cr_running flag). Internally frame also has an executing flag.

We use these, plus the test `f_stacktop pointer == NULL`, to determine what state a generator or frame is in.

It would be much cleaner to maintain a single f_state field in the frame to track the state of a frame, reducing the change of ambiguity and error.

The possible states of a frame are:
CREATED -- Frame exists but has not been executed at all
SUSPENDED -- Frame has been executed, and has been suspended by a yield
EXECUTING -- Frame is being executed
RETURNED -- Frame has completed by a RETURN_VALUE instruction
RAISED -- Frame has completed as a result of an exception being raised
CLEARED -- Frame has been cleared, either by explicit call to clear or by the GC.

----------
assignee: Mark.Shannon
components: Interpreter Core
messages: 371194
nosy: Mark.Shannon
priority: normal
severity: normal
stage: needs patch
status: open
title: Merge generator.gi_running and frame executing flag into single frame state
type: performance

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40941>
_______________________________________


More information about the New-bugs-announce mailing list