Nick Coghlan wrote:
PEP 3152 (and all generator based coroutines) have the limitation that they can't suspend if there's a *Python* function on the stack. Can you see why I know consider this approach categorically worse than one that pursued the Lua approach?
Can you give a concrete example of this problem? Even a toy example will do. The only thing I can think of is something like this:
def function(co): value = 1000 for i in (1, 2, 3): value -= co.send(i) return value
def coroutine(): value = (yield 1) while True: value += 1 print("suspending...") value += (yield value) print("waking...")
co = coroutine() co.send(None)
waking... suspending... waking... suspending... waking... suspending... 972
waking... suspending... 24
But as far as I understand it, that seems to show the coroutine suspending even though a function is on the stack. Can you explain what you mean and/or how I have misunderstood?