append in IMAP4 from imaplib very slow

Simon Pirschel sp at abusix.org
Wed Jul 25 13:47:59 EDT 2012


Hi,

I'm currently experimenting with IMAP using Python 2.7.3 and IMAP4 from 
imaplib. I noticed the performance to be very bad. I read 5000 files 
from a directory and append them to an IMAP INBOX. The hole procedure of 
reading and appending is taking about 210 seconds.

I set up the exact same code in Perl to check if there is a general IMAP 
server configuration issue, since CPU and I/O isn't the problem. The 
same amount of data on the same IMAP server is done after 7.9 seconds 
using Perl.

The difference is huge and I tried to narrow the issue down by profiling 
the Python code.
The profile results are, 206 seconds are spent in calling socket.recv.

Python Code: <http://pastebin.com/EWnfpsZB>http://pastebin.com/d2c9d4Dx
Profile Result: http://pastebin.com/rWCS8tAz
Perl Code: http://pastebin.com/ZV3Yv74d

Maybe someone can explain what's the problem, or help me debugging the 
issue.

Thanks,
Simon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120725/03719e21/attachment.html>


More information about the Python-list mailing list