Python/Erlang:Twisted、Stackless、Greenlet、Eventlet、协程之间有什么区别?它们与 Erlang 进程相似吗?
我不完全的理解是,Twisted、Stackless、Greenlet、Eventlet、Coroutines 都利用了非常轻量级且快速切换的异步网络 IO 和用户态线程。但我不确定它们之间有什么区别。
而且它们听起来与 Erlang 进程非常相似。它们几乎是同一件事吗?
任何可以帮助我更多地理解这个主题的人将不胜感激。
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 to switch. But I'm not sure what are the differences between them.
Also they sound very similar to Erlang processes. Are they pretty much the same thing?
Anyone who could help me understand this topic more would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先,非阻塞 I/O 与绿色线程或协程没有任何共同之处,但它会影响它们的调度方式。
现在:
First of all, non-blocking I/O has nothing in common with green threads or coroutines, but it can affect how they're scheduled.
Now:
比较 Stackless 时你几乎是对的
到格林莱特。缺少的是:
Stackless 本身并没有添加某些东西。相反,在 Stackless 5 年后发明的 Greenlet 删除了某些东西。它编写得足够简单,可以构建为扩展模块而不是替代解释器。
这真的很有趣——Stackless 有更多的功能,切换效率大约是原来的 10 倍,并且提供执行状态的 pickling。
Greenlet 仍然获胜,可能只是因为作为扩展模块易于使用。因此,我正在考虑通过酸洗扩展 Greenlet 来恢复该过程。也许这会再次改变情况:-)
You are almost right when comparing Stackless
to Greenlet. The missing thing is:
Stackless per se does not add something. Instead, Greenlet, invented 5 years after Stackless, removes certain things. It is written simple enough to be built as an extension module instead of a replacement interpreter.
This is really funny—Stackless has many more features, is about 10 times more efficient on switching, and provides pickling of execution state.
Greenlet still wins, probably only due to ease of use as an extension module. So I'm thinking about reverting the process by extending Greenlet with pickling. Maybe that would change the picture, again :-)
诱饵上钩了! (欢迎修复!):
严重:
这些都不像 Erlang 进程那样轻量或得到良好支持。
Bait taken! (fixes welcome!):
Grossly:
None of these are as light or well-supported as Erlang processes.