Under what circumstances would something like eventlet/gevent be better than twisted? Twisted seems like the most used, but eventlet/gevent must have some advantages... I'm not looking for an answer to a specific scenario, just generalities.
在什么情况下,像eventlet/gevent这样的东西会比twisted更好?Twisted matrix似乎最常用,但eventlet/gevent肯定有一些优势……我不是在寻找某个特定场景的答案,只是笼统的回答。
1 个解决方案
#1
10
It's an issue of aesthetic preference, I think.
我认为这是一个审美偏好的问题。
First of all, eventlet can actually use Twisted for networking, so in a sense, it's not an either-or question, it's a this-is-built-on-top-of-that question.
首先,eventlet实际上可以使用Twisted来建立网络,因此,从某种意义上来说,这不是一个非此即彼的问题,而是一个“在那个问题之上构建这个”的问题。
Personally, I don't see the need for libraries like gevent or eventlet, especially since the advent of the @inlineCallbacks
decorator in Twisted, which already write code which sorta looks like it's blocking.
就我个人而言,我不认为需要像gevent或eventlet这样的库,尤其是在Twisted中出现了@inlineCallbacks decorator,它已经编写了看起来像是在阻塞的代码。
But, if you have a large library of code which already uses threads, and you want to port it to be event-driven, something like eventlet can save you some typing, since you don't need to insert 'yield
's everywhere.. Some people, like the guys behind the EVE online game, think that code written in this style is just better for some things, such as AI code.
但是,如果您有一个已经使用了线程的大型代码库,并且您想要将它移植为事件驱动的,像eventlet之类的东西可以为您节省一些输入,因为您不需要在任何地方插入“yield’s everywhere”。有些人,比如玩EVE在线游戏的那些人,认为用这种风格编写的代码对某些东西更好,比如人工智能代码。
#1
10
It's an issue of aesthetic preference, I think.
我认为这是一个审美偏好的问题。
First of all, eventlet can actually use Twisted for networking, so in a sense, it's not an either-or question, it's a this-is-built-on-top-of-that question.
首先,eventlet实际上可以使用Twisted来建立网络,因此,从某种意义上来说,这不是一个非此即彼的问题,而是一个“在那个问题之上构建这个”的问题。
Personally, I don't see the need for libraries like gevent or eventlet, especially since the advent of the @inlineCallbacks
decorator in Twisted, which already write code which sorta looks like it's blocking.
就我个人而言,我不认为需要像gevent或eventlet这样的库,尤其是在Twisted中出现了@inlineCallbacks decorator,它已经编写了看起来像是在阻塞的代码。
But, if you have a large library of code which already uses threads, and you want to port it to be event-driven, something like eventlet can save you some typing, since you don't need to insert 'yield
's everywhere.. Some people, like the guys behind the EVE online game, think that code written in this style is just better for some things, such as AI code.
但是,如果您有一个已经使用了线程的大型代码库,并且您想要将它移植为事件驱动的,像eventlet之类的东西可以为您节省一些输入,因为您不需要在任何地方插入“yield’s everywhere”。有些人,比如玩EVE在线游戏的那些人,认为用这种风格编写的代码对某些东西更好,比如人工智能代码。