[Python-Dev] Python 2.3b1 has 20% slower networking?

Skip Montanaro skip@pobox.com
Mon, 28 Apr 2003 09:32:23 -0500

    Itamar> If this slowdown is confirmed, it is really not acceptable,
    Itamar> since the change seems to have been made only to support making
    Itamar> timeout sockets slightly easier to use. 

It was done to support making timeout sockets work properly.  As they
existed previously, timeout sockets wouldn't work with protocols which would
most likely use them: higher level modules such as httplib, which call
sock.makefile(), then call readlines?() on the resulting file object.

    Itamar> Why should everyone have to pay a speed penalty just so a
    Itamar> minority of people can skip calling a
    Itamar> "socket.installtimeoutsupport()" at the beginning of their
    Itamar> program? it's just one line of code they'd need to add.

I think it would be easier for the minority of programs that care about the
20% performance loss to simply set

    import socket, _socket
    socket.socket = socket.SocketType = _socket.socket

I don't know about you, but fast and incorrect don't help me much.

Feel free to submit a patch which improves performance but maintains proper
behavior in the face of timeouts (that is, allows test_urllibnet to still
work correctly).