[Python-ideas] yield from multiple iterables (was Re: The async API of the future: yield-from)
Christian Tismer
tismer at stackless.com
Fri Oct 19 14:05:20 CEST 2012
On 19.10.12 07:15, Greg Ewing wrote:
> Christian Tismer wrote:
>
>> - generators are able to free the stack, when they yield. But when they
>> are active, they use the full stack. At least when I follow the
>> pattern
>> "generator is calling sub-generator".
>> A deeply nested recursion is therefore something to avoid. :-(
>
> Only if yield-from chains aren't optimised the way they
> used to be.
Does that mean a very deep recursion would be efficient?
I'm trying to find that change in the hg history right now.
Can you give me a hint how your initial implementation
works, the initial patch source?
>
> ...
>> But this function that wants to
>> switch needs to pass the fact that it wants to switch, plus the target
>> somewhere. As I understood it, I would need to yield that to the
>> driver function.
>
> You understand incorrectly. In my scheduler, the yields
> don't send or receive values at all. Communicating with the
> scheduler, for example to tell it to allow another task to
> run, is done by calling functions. A yield must be done to
> actually allow a switch, but the yield itself doesn't send
> any information.
I have studied that yesterday already in depth and like that quite much.
It is probably just the problem that I had with generators from their
beginning.
--
Christian Tismer :^) <mailto:tismer at stackless.com>
Software Consulting : Have a break! Take a ride on Python's
Karl-Liebknecht-Str. 121 : *Starship* http://starship.python.net/
14482 Potsdam : PGP key -> http://pgp.uni-mainz.de
phone +49 173 24 18 776 fax +49 (30) 700143-0023
PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04
whom do you want to sponsor today? http://www.stackless.com/
More information about the Python-ideas
mailing list