imap_copy icon indicating copy to clipboard operation
imap_copy copied to clipboard

Faster approach on high latency connections

Open teambob opened this issue 11 years ago • 0 comments

I live in Australia which means I have a high latency to the US. I was recently migrating from a US server to Australia and the migration was somewhat slow.

It would be much faster on high latency connections to download a batch of messages or all messages.

Note that the list is comma separated, not space separated. When downloading multiple messages imaplib seems to have a bug where for each message there is a ')'. So msg[0] is the proper message and msg[1] contains ')'

msgnums = data[0].split() In [58]: len(msgnums) Out[58]: 426

In [17]: %time status, msgs = conn.fetch(",".msgnums), '(RFC822 FLAGS)') CPU times: user 478 ms, sys: 743 ms, total: 1.22 s Wall time: 20.1 s

In [18]: len(msgs) Out[18]: 852

Existing way: %time single_msgs=[conn.fetch(msgnum, '(RFC822 FLAGS)') for msgnum in msgnums] CPU times: user 617 ms, sys: 788 ms, total: 1.4 s Wall time: 2min 51s

In [55]: len(single_msgs) Out[55]: 426

teambob avatar Aug 16 '14 23:08 teambob