On Nov 3, 4:13 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Mon, 03 Nov 2008 21:09:58 +0000, Jorgen Grahn wrote:
> > Why multi-threading?  I see no concurrency in the original algorithm.
> > There is, in my mind, nothing concurrent about 'yield'.
>
> No "real" concurrency but a generator can be seen as independent thread
> of code where the generator code is allowed to run when `next()` is
> called and stops itself when it ``yield``\s an object.  Sort of
> cooperative multitasking.  The name "yield" is often used in concurrent
> code like Java's or Io's `yield()` methods.
>
> Ciao,
>         Marc 'BlackJack' Rintsch

Further, it resumes where it left off when it gets control again:

"execution is stopped at the yield keyword (returning the result) and
is resumed there when the next element is requested by calling the
next() method" --the fine manual

It maintains and operates in its own separate execution frame, etc.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to