]> granicus.if.org Git - python/commitdiff
Issue #1441530: In imaplib, read the data in one chunk to speed up large
authorCharles-François Natali <neologix@free.fr>
Tue, 24 May 2011 21:47:49 +0000 (23:47 +0200)
committerCharles-François Natali <neologix@free.fr>
Tue, 24 May 2011 21:47:49 +0000 (23:47 +0200)
reads and simplify code.

Lib/imaplib.py
Misc/NEWS

index 142e27bc87b239ca6c020975075fc2accc0c7bfd..1b540655f2834cfc1dac0d12a88314bf7280f1bd 100644 (file)
@@ -249,15 +249,7 @@ class IMAP4:
 
     def read(self, size):
         """Read 'size' bytes from remote."""
-        chunks = []
-        read = 0
-        while read < size:
-            data = self.file.read(min(size-read, 4096))
-            if not data:
-                break
-            read += len(data)
-            chunks.append(data)
-        return b''.join(chunks)
+        return self.file.read(size)
 
 
     def readline(self):
index 917dfe3ab396c47ae9a4fc0b715ecd02477ebe81..68130a92ee117d1e1972ebc52b5aa7652e6d8d59 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -161,6 +161,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #1441530: In imaplib, read the data in one chunk to speed up large
+  reads and simplify code.
+
 - Issue #12070: Fix the Makefile parser of the sysconfig module to handle
   correctly references to "bogus variable" (e.g. "prefix=$/opt/python").