Coroutine vs Continuation vs Generator

后端 未结 3 1065
伪装坚强ぢ
伪装坚强ぢ 2020-12-02 03:28

What is the difference between a coroutine and a continuation and a generator ?

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-02 04:21

    In newer version of Python, you can send values to Generators with generator.send(), which makes python Generators effectively coroutines.

    The main difference between python Generator, and other generator, say greenlet, is that in python, your yield value can only return back to the caller. While in greenlet, target.switch(value) can take you to a specific target coroutine and yield a value where the target would continue to run.

提交回复
热议问题