[Twisted-Python] POP3 improvements

Andrew Bennetts andrew-twisted at puzzling.org
Tue Dec 31 01:36:40 EST 2002

On Mon, Dec 30, 2002 at 11:27:23AM -0500, Abe Fettig wrote:
> Over the weekend I was working on adding POP3 support to the messaging
> library I'm working on.  I noticed that while downloading large messages
> from a POP3 server on my local network my test app would use 100% CPU,
> and would stop responding to events until it finished downloading the
> message.  
> Looking at the twisted.protocols.pop3.POP3Client code I saw that it was
> handling downloaded messages by concatenating a string, adding one line
> at a time.  This seemed like an inefficient way to do it, so I modified
> the code to use a file-like object instead.  The result is much faster,
> and gives you the option of writing a downloading message to a file as
> it comes in rather than keeping it all in memory.

Hang on... POP3Client *doesn't* do any concatenation.  Looking at it, it
merely fires handle_COMMAND, possibly followed by multiple
handle_COMMAND_continue and a handle_COMMAND_end, and at no time is more
than one line passed around.

Perhaps you mean basic.LineReceiver does concatenation?  How long are the
lines you are receiving?

If basic.LineReceiver is the culprit, I suspect it would make more sense to
fix it there than in POP3Client.


More information about the Twisted-Python mailing list