On 3 Nov 2008 22:13:42 GMT, 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.
Sort of ... I find it more useful to see it as an object, or something with a state. And I think it's a bad idea to rewrite an algorithm using threads in order to simulate generators. > The name "yield" is often used in concurrent > code like Java's or Io's `yield()` methods. That's a completely unrelated yield, isn't it? Meanings (1) and (3) respectively in http://en.wiktionary.org/wiki/yield: - To give way; to allow another to pass first. - To produce as return, as from an investment. /Jorgen -- // Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.se> R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list