summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/socket.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/socket.py b/Lib/socket.py
index 833a456..0daeadc 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -307,6 +307,17 @@ class _fileobject(object):
data = self._rbuf
if size < 0:
# Read until \n or EOF, whichever comes first
+ if self._rbufsize <= 1:
+ # Speed up unbuffered case
+ assert data == ""
+ buffers = []
+ recv = self._sock.recv
+ while data != "\n":
+ data = recv(1)
+ if not data:
+ break
+ buffers.append(data)
+ return "".join(buffers)
nl = data.find('\n')
if nl >= 0:
nl += 1