Christian Tismer wrote:
Can you give me a hint how your initial implementation works, the initial patch source?
You can find my initial patches here: http://www.cosc.canterbury.ac.nz/greg.ewing/python/generators/yield_from.htm... Essentially, an extra field f_yieldfrom is added to frame objects. When a 'yield from' is started, the f_yieldfrom field of the calling frame is set to point to the called frame. The __next__ method of a generator first traverses the f_yieldfrom chain to find the frame at the end, and then resumes that frame. So most of the time, only the innermost frame of a nested yield-from chain is actually entered in response to a next() call. (There are some complications due to the fact that you can 'yield from' something that's not a generator, but the above is effectively what happens when all the objects in the chain are generators.) -- Greg