Stackless & String-processing
Neel Krishnaswami
neelk at brick.cswv.com
Thu Jul 15 20:27:03 EDT 1999
In article <000601bece8f$b549a420$51a22299 at tim>,
Tim Peters <tim_one at email.msn.com> wrote:
>[Neel Krishnaswami]
>
>> (I'd love to be able to define coroutines in Python like so:
>>
>> def evens(z):
>> for elt in z:
>> if z % 2 == 0:
>> suspend(elt)
>
>
>> It would probably require some rethinking of Python's iteration
>> protocol though.)
>
>How do you intend to resume it?
I left this unspecified because I don't know the answer. :) I figured
that it could be rolled up into the iteration protocol and I could
use it without having to completely understand how it all works.
[The iteration protocol]
>That's not a hangup; Guido already knows how to do it cleanly.
Good -- now I don't have to worry at all.
>BTW, generators are much easier to implement than coroutines -- the former
>don't require threads or stacklessness or continuations under the covers,
>just some relatively straightforward changes to Python's current
>implementation (Steven Majewski noted this 5 years ago).
What's the difference, exactly? AFAICT you need to save the execution
state when suspending both coroutines and generators, but I might be
missing something obvious....
Neel
More information about the Python-list
mailing list