diff options
| author | Guido van Rossum <guido@python.org> | 2002-08-08 17:34:19 +0000 |
|---|---|---|
| committer | Guido van Rossum <guido@python.org> | 2002-08-08 17:34:19 +0000 |
| commit | 6a532f830458c8fb8ce79f18b56751aaa273a173 (patch) | |
| tree | 58130221356ef43411a0799567302f0a7f9c23d5 /Lib/socket.py | |
| parent | 7dca71e7bb1fe5ba57c2230463343a7a23dd9754 (diff) | |
| download | cpython-6a532f830458c8fb8ce79f18b56751aaa273a173.tar.gz | |
OK, one more hack: speed up the case of readline() in unbuffered mode.
This is important IMO because httplib reads the headers this way.
Diffstat (limited to 'Lib/socket.py')
| -rw-r--r-- | Lib/socket.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/socket.py b/Lib/socket.py index 833a456b4f..0daeadcb34 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 |
