[Python-Dev] Twisted Isn't Specific (was Re: Trial balloon: microthreads library in stdlib)
jcarlson at uci.edu
Thu Feb 15 22:55:31 CET 2007
Jean-Paul Calderone <exarkun at divmod.com> wrote:
> On Thu, 15 Feb 2007 02:36:22 -0700, Andrew Dalke <dalke at dalkescientific.com> wrote:
> >2) asyncore is
> >smaller and easier to understand than Twisted,
> While I hear this a lot, applications written with Twisted _are_ shorter and
> contain less irrelevant noise in the form of boilerplate than the equivalent
> asyncore programs. This may not mean that Twisted programs are easier to
> understand, but it is at least an objectively measurable metric.
In my experience, the boilerplate is generally incoming and outgoing
buffers. If both had better (optional default) implementations, and
perhaps a way of saying "use the default implementations of handle_close,
etc.", then much of the boilerplate would vanish. People would likely
implement a found_terminator method and be happy.
> >3) it was for demo/proof of concept purposes.
> >tempting to improve that module I know that Twisted
> >has already gone though all the platform-specific crap
> >and I don't want to go through it again myself. I don't
> >want to write a reactor to deal with GTK, and one for
> >OS X, and one for ...
> Now if we can only figure out a way for everyone to benefit from this without
> tying too many brains up in knots. :)
Whenever I need to deal with these kinds of things (in wxPython
specifically), I usually set up a wxTimer to signal
asyncore.poll(timeout=0), but I'm lazy, and rarely need significant
throughput in my GUI applications.
> >Yet by using the Stackless socket monkeypatch, this
> >same code works in an async framework. And the underlying
> >libraries have a much larger developer base than Twisted.
> >Want NNTP? "import nntplib" Want POP3? "import poplib"
> >Plenty of documentation about them too.
> This is going to come out pretty harshly, for which I can only apologize in
> advance, but it bears mention. The quality of protocol implementations in the
> standard library is bad. As in "not good". Twisted's NNTP support is better
> (even if I do say so myself - despite only having been working on by myself,
> when I knew almost nothing about Twisted, and having essentially never been
> touched since). Twisted's POP3 support is fantastically awesome. Next to
> imaplib, twisted.mail.imap4 is a sparkling diamond. And each of these
> implements the server end of the protocol as well: you won't find that in the
> standard library for almost any protocol.
Protocol support is hit and miss. NNTP in Python could be better, but
that's not an asyncore issue (being that nntplib isn't implemented using
asyncore), that's an "NNTP in Python could be done better" issue. Is it
worth someone's time to patch it, or should they just use Twisted? Well,
if we start abandoning stdlib modules, "because they can always use
Twisted", then we may as well just ship Twisted with Python.
More information about the Python-Dev