Twisted vs POS (Plain-old sockets)

Jean-Paul Calderone exarkun at divmod.com
Sun Sep 3 12:07:03 EDT 2006


On Sun, 3 Sep 2006 00:19:17 -0700, Darren Kirby <bulliver at gmail.com> wrote:
>Hey all,
>
>I have a (FOSS) project here that I am about to start that requires TCP
>networking support, and in fact, will require me to design and implement a
>(text based) protocol from scratch.

I'm sorry.

>
>I have been playing with Twisted today and managed to get a simple
>client/server talking to each other. However, the twisted framework does
>seem
>very complex, and includes many, many, features I will never need. The docs
>seem a little lacking (or perhaps just confusing) as well. Twisted's good
>points are that it will save me from having to write many things from
>scratch, asynchronous networking being the biggie.

If there are features you don't need, then don't use them.  What does their
existence cost you?  Are you going to use the sunaudio module from the
standard library?  If not, is this an argument in favor of using C++ instead
of Python?

As for documentation, many people say it is lacking, but perhaps one person
in a thousand points out _how_ or _where_ it is lacking.  Unfortunately it
is difficult to improve things (or even determine if they really are lacking)
with this level of feedback.

Keep in mind that in addition to the online documentation, there is a Twisted
book, an extremely helpful twisted mailing list (with years of archives
online), and an IRC channel populated at nearly all hours of the day with
people who can answer Twisted questions.

>
>I guess I am wondering if given the fact I need a custom protocol, and need
>to
>talk TCP/IP should I stick with twisted or just use plain old sockets and
>build it myself?

Talking to the TCP/IP stack is surprisingly difficult to get right.  Since
it is extremely unlikely that you actually _care_ about all of the random,
stupid differences between different TCP implementations, you should use
Twisted, since it does its best to hide these differences and instead
present a uniform API.

If you use bare sockets, you will need to learn many of these quirks yourself,
frequently through a bug report from a user, since many of them are
undocumented.

>Is there a third option I should consider? Have others
>found
>themselves in this situation? Thoughts? Comments? I am really just fishing
>for opinions here...

Twisted is great.  It will speed up your development time and reduce the
amount of defects you need to deal with.  It will 

>
>If it makes a difference: Depending on performance parts of this app may
>well
>end up as a prototype for a final (...alternative?) C++ implementation.
>
>Thanks for consideration,

Hope this helps,

Jean-Paul



More information about the Python-list mailing list