[PATCH 0/13] Reintegrate imaplib2 and IDLE, again

Ethan ethan.glasser.camp at gmail.com
Mon Feb 7 16:11:33 GMT 2011

On Mon, Feb 7, 2011 at 6:35 AM, Sebastian Spaeth <Sebastian at sspaeth.de> wrote:
> On Sun,  6 Feb 2011 11:58:54 -0500, Ethan Glasser-Camp <ethan at betacantrips.com> wrote:
> > - Patch 5: Remove WrappedIMAP4_SSL.read(). This overridden method
> >   seemed to be built to interact with imaplib, but with imaplib2,
> >   it prevents SSL from working. We seem to be OK without it...
> Hi there,
> cool work. I will try it out when I have some time. Just one comment on
> the imaplib.read() implementation (because I had asked John why we
> override this very function):
> IMAP4_SSL.readline() implements a VERY inefficient solution, it reads
> one char at a time, and copies all those fragments together to full
> strings. It really sucks! That's why we have a custom _read_upto()
> function which reads (I believe around 4kb) in one go, and buffers the
> rest that we don't need for our readline(). That is why we also need to
> override read(), so we get data that we have in that buffer first before
> actually reading in new data.

imaplib2 doesn't define or use any method called readline(), as far as
I can tell. See for yourself:

ethan at jonah-hex:~$ curl -s
http://sydney.edu.au/engineering/it/~piers/python/imaplib2 | head
#!/usr/bin/env python

"""Threaded IMAP4 client.

Based on RFC 2060 and original imaplib module.

Public classes:   IMAP4

ethan at jonah-hex:~$ curl -s
http://sydney.edu.au/engineering/it/~piers/python/imaplib2 | grep
ethan at jonah-hex:~$

> So, while it would be possible to ditch _read_upto(), read(), and
> .readline() for the SSL case (but just ditching read() and keeping
> readline() wouldnt work!), we would get the performance penalty that
> this implementation overcomes.

Since imaplib2 doesn't define or use readline or _read_upto, and we
don't call it directly ourselves, we should be able to delete them all
without a problem. When I sent the patch, I hadn't yet grepped the
codebase for use of these methods, so wasn't sure if they were being
used somewhere.


More information about the OfflineIMAP-project mailing list