Unyeilding a permutation generator
Jorgen Grahn
grahn+nntp at snipabacken.se
Tue Nov 4 14:27:56 EST 2008
On 3 Nov 2008 22:13:42 GMT, Marc 'BlackJack' Rintsch <bj_666 at gmx.net> 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!
More information about the Python-list
mailing list