(semi) stackless python
John DeWeese
deweese at usc.edu
Thu Dec 20 16:16:41 EST 2001
> The new generators in Python2.2 implement semi-coroutines, not
> full coroutines: the limitation is that they always return to
> their caller -- they can't take an arbitrary continuation as
> a return target.
>
> So you can't do everything you can do in Stackless, or at least,
> you can't do it the same way. I'm not sure what the limitations
> are yet, but you might be surprised with what you CAN do.
> If all the generator objects yield back to the same 'driver'
> procedure, then you can do a sort of cooperative multithreading.
> In that case, you're executing the generators for their side
> effects -- the value returned by yield may be unimportant except
> perhaps as a status code.
>
> [ See also Tim Peters' post on the performance advantages of
> generators -- you only parse args once for many generator
> calls, and you keep and reuse the same stack frame. So I
> believe you get some of the same benefits of Stackless
> microthreads. ]
>
> Maybe I can find the time to post an example of what I mean.
> In the mean time, some previous posts on generators might give
> you some ideas.
Thanks, I will do some research on generators. If they are sufficient, I
would be able to stick to the latest python.
- John
More information about the Python-list
mailing list