[issue2632] performance problem in socket._fileobject.read

Curt Hagenlocher report at bugs.python.org
Tue Apr 15 22:45:16 CEST 2008


Curt Hagenlocher <curt at hagenlocher.org> added the comment:

At least in 2.5.2, there appear to be only two places in the standard 
library where an arbitrary and unchecked size is passed directly to 
_socketobject.recv.  _fileobject.read is one such place and the other 
is in logging/config.py.  In both cases, the pattern is something like

while len(data) < size:
    data = data + sock.recv(size - len(data))

Of course, the same pattern may exist in any number of instances of 
user code that performs a socket.recv, and all of these would be 
subject to the same memory thrashing problem that originally beset 
imaplib.

As such, I now agree with Ralf that the fix ultimately belongs in 
_socketobject.  However, deploying a fix for 2.5.2 is probably easier 
if it's in socket.py than if it requires a recompile.

----------
title: socket._fileobject.read(n) should ignore _rbufsize when 1 -> performance problem in socket._fileobject.read

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2632>
__________________________________


More information about the Python-bugs-list mailing list