PEP 255: Simple Generators

Robin Becker robin at jessikat.fsnet.co.uk
Sat Jun 16 20:07:52 EDT 2001


In article <mailman.992637984.7027.python-list at python.org>, Tim Peters
<tim.one at home.com> writes
>[Robin Becker]
>> Who owns the generator state is it the caller or the callee?
>
>Neither:  it's part of the generator-iterator.  Under the covers, it's
>simply the callee's activation record ("frame"); the primary trick to
>implementing generators is simply to refrain from decrementing the frame's
>refcount when leaving the function.  The generator-iterator holds a
>reference to the frame instead, and the frame will be discarded as a matter
>of course when the iterator becomes trash.
>
>
so the implication is that the state can't be got at explicitly and I
have to redefine the generator function part of the iterator to reset
it? can one copy a generator-iterator?
-- 
Robin Becker



More information about the Python-list mailing list