[Python-Dev] Extended Function syntax

Tim Peters tim.one@comcast.net
Mon, 03 Feb 2003 12:07:47 -0500


[holger krekel]
> What do you mean with "generator's stack frame is popped"?

At the end of eval_frame():

	/* pop frame */
	--tstate->recursion_depth;
	tstate->frame = f->f_back;

	return retval;

The current frame is always popped from the thread state's frame stack,
regardless of the reason for leaving eval_frame() (and generator yield is
identical to function return in this respect).

> I interpreted this code in ceval.c
>
>     if (why != WHY_YIELD) {
>             /* Pop remaining stack entries -- but when yielding */
>             while (!EMPTY()) {
>                 v = POP();
>                 Py_XDECREF(v);
>             }
>     }
>
> to mean the frame is suspended with a preserved stack.
> f_stacktop/last_i later are used to resume.

Like that's news to me <wink>.  Until it is resumed, the frame doesn't
appear anywhere on the thread state's stack -- it would be lost entirely
except that a generator-iterator object still holds a reference to it