
Vladimir Marangozov wrote: ...
too-simple-to-be-obvious?-ly y'rs - tim
Yes. I'm trying to understand the following:
1. What does a generator generate?
Trying my little understanding. A generator generates a series of results if you ask for it. That's done by a resume call (generator, resume your computation), and the generate continues until he either comes to a suspend (return a value, but be prepared to continue from here) or it does a final return.
2. Clearly, what's the difference between a generator and a thread?
Threads can be scheduled automatically, and they don't return values to each other, natively. Generators are asymmetric to their callers, they're much like functions. Coroutines are more symmetric. They "return" to each other values. They are not determined as caller and callee, but they cooperate on the same level. Therefore, threads and coroutines look more similar, just that coroutines usually are'nt scheduled automatically. Add a scheduler, don't pass values, and you have threads, nearly. (of course I dropped the I/O blocking stuff which doesn't apply and isn't the intent of fake threads). ciao - chris -- Christian Tismer :^) <mailto:tismer@appliedbiometrics.com> Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home