[Python-Dev] Anonymous blocks: Thunks or iterators?
Jim Jewett
jimjjewett at gmail.com
Fri Apr 29 20:33:54 CEST 2005
On 4/29/05, Brian Sabbey <sabbey at u.washington.edu> wrote:
> Jim Jewett wrote:
> > The only members that need special attention are (f_code, f_lasti)
> > and possibly (f_blockstack, f_iblock).
> You don't even need to take care of f_code. The thunk and its surrounding
> function can share the same code. The thunk gets compiled into the
> function the same way the body of a for loop would.
This only works if you already know what the thunk's code will be
when you compile the function. (Just splicing it in messes up jump
targets.)
> One also needs to store f_back, and, to avoid exception weirdness,
> f_exc_XXX.
f_back lists the previous stack frame (which shouldn't change during
a thunk[1]), and f_exc_XXX is for the most recent exception -- I don't see
any reason to treat thunks differently from loop bodies in that regard.
[1] If the thunk calls another function (that needs its own frame), then
that is handled the same as any regular function call.
-jJ
More information about the Python-Dev
mailing list