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

Guido van Rossum guido@python.org
Mon, 28 Apr 2003 10:29:55 -0400

I'm guessing that the slowdown comes from the fact that calling a
method like recv() on the wrapper object is now a Python method which
calls the C method on the wrapped object.

I wonder if the slowdown can't be easily repaired by changing the
wrapper class to copy the relevant methods to instance variables.

It would be even nicer to use subclassing instead of a wrapper
object.  I vaguely recall that I tried this before but couldn't figure
out how to do it, but I've got a feeling that it ought to be doable --
after all the C socket object has separate __new__ and __init__

I hope someone can take this ball and submit a patch -- it would
indeed be a shame to have to live with the slowdown (even if it only
shows up when using the loopback device) or to have a practice of
monkey patching socket.py.  (BTW instead of monkey-patching socket.py,
it might be easier to write "import _socket as socket".)

--Guido van Rossum (home page: http://www.python.org/~guido/)