Python/Erlang: What's the difference between Twisted, Stackless, Greenlet, Eventlet, Coroutines? Are they similar to Erlang processes?

后端 未结 3 463
清酒与你
清酒与你 2021-01-30 00:19

My incomplete understanding is that Twisted, Stackless, Greenlet, Eventlet, Coroutines all make use of async network IO and userland threads that are very lightweight and quick

3条回答
  •  自闭症患者
    2021-01-30 01:02

    Bait taken! (fixes welcome!):

    Grossly:

    • twisted: single threaded. achieves non-blocking behaviour via use of 'callbacks' and 'deferred' idioms. Similar to node.js.
    • greenlet / eventlet : use 'green threads' (sections of memory?) to achieve non-blocking io. Actually patches the standard CPython IO with their versions, so code is still written as though it is blocking / sequential.
    • stackless: http://www.stackless.com/. Haven't used it, looks like it adds 'microthreads' and other niceties? stackless example idioms
    • coroutines: coroutines on SO

    None of these are as light or well-supported as Erlang processes.

提交回复
热议问题