summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSkip Montanaro <skip@pobox.com>2003-04-29 19:27:26 (GMT)
committerSkip Montanaro <skip@pobox.com>2003-04-29 19:27:26 (GMT)
commitc689918c941d366716c9a630414fb6703581b425 (patch)
tree2b1bed403a1d3d4618a018bad79a25ce1f8b99b6
parent26848a34d100f5ff9c3f2710d321d68f73204005 (diff)
downloadcpython-c689918c941d366716c9a630414fb6703581b425.zip
cpython-c689918c941d366716c9a630414fb6703581b425.tar.gz
cpython-c689918c941d366716c9a630414fb6703581b425.tar.bz2
Regain throughput lost with the _socketobject wrapper. The
throughput-sensitive methods are grabbed from the underlying _socket.socket object. Closes SF patch 729293.
-rw-r--r--Lib/socket.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/Lib/socket.py b/Lib/socket.py
index 12f3c05..b9d4049 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -131,27 +131,33 @@ def getfqdn(name=''):
_socketmethods = (
'bind', 'connect', 'connect_ex', 'fileno', 'listen',
'getpeername', 'getsockname', 'getsockopt', 'setsockopt',
- 'recv', 'recvfrom', 'send', 'sendall', 'sendto', 'setblocking',
+ 'sendall', 'setblocking',
'settimeout', 'gettimeout', 'shutdown')
class _closedsocket(object):
__slots__ = []
- def __getattr__(self, name):
+ def _dummy(*args):
raise error(9, 'Bad file descriptor')
+ send = recv = sendto = recvfrom = __getattr__ = _dummy
class _socketobject(object):
__doc__ = _realsocket.__doc__
- __slots__ = ["_sock"]
+ __slots__ = ["_sock", "send", "recv", "sendto", "recvfrom"]
def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None):
if _sock is None:
_sock = _realsocket(family, type, proto)
self._sock = _sock
+ self.send = self._sock.send
+ self.recv = self._sock.recv
+ self.sendto = self._sock.sendto
+ self.recvfrom = self._sock.recvfrom
def close(self):
self._sock = _closedsocket()
+ self.send = self.recv = self.sendto = self.recvfrom = self._sock._dummy
close.__doc__ = _realsocket.close.__doc__
def accept(self):