[Patches] [ python-Patches-729293 ] Regain speed lost w/ timeout change

SourceForge.net noreply@sourceforge.net
Tue, 29 Apr 2003 12:20:59 -0700


Patches item #729293, was opened at 2003-04-28 22:02
Message generated for change (Comment added) made by gvanrossum
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=729293&group_id=5470

Category: Library (Lib)
Group: Python 2.3
Status: Open
>Resolution: Accepted
Priority: 5
Submitted By: Skip Montanaro (montanaro)
>Assigned to: Skip Montanaro (montanaro)
Summary: Regain speed lost w/ timeout change

Initial Comment:
The speed loss reported by the Twisted folks today is fairly easy
to work around.  The attached patch implements it in one
possible way.  I've never used new-style classes before, however,
so the patch looks ugly to me.  Maybe that's just the way you have
to do things with new-style classes.  Then again, maybe there's
a better way to do it.


----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2003-04-29 15:20

Message:
Logged In: YES 
user_id=6380

Yep!

----------------------------------------------------------------------

Comment By: Skip Montanaro (montanaro)
Date: 2003-04-29 15:18

Message:
Logged In: YES 
user_id=44345

Works for me.  Shall I check it in and be done with it?


----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2003-04-29 10:29

Message:
Logged In: YES 
user_id=6380

Strange.  I don't see that. I'm uploading something that
works for me with the throughput test, as well as passing
the unit test suite.

----------------------------------------------------------------------

Comment By: Skip Montanaro (montanaro)
Date: 2003-04-29 08:48

Message:
Logged In: YES 
user_id=44345

The conditional check was part of the "ugly" I was talking about.  Without
them I get

Traceback (most recent call last):
  File "/Users/skip/src/python/head/dist/src/Demo/sockets/throughput.py", 
line 93, in ?
    main()
  File "/Users/skip/src/python/head/dist/src/Demo/sockets/throughput.py", 
line 27, in main
    server()
  File "/Users/skip/src/python/head/dist/src/Demo/sockets/throughput.py", 
line 46, in server
    s = socket(AF_INET, SOCK_STREAM)
  File "/Users/skip/src/python/head/dist/src/Lib/socket.py", line 152, in 
__init__
    self.send = self._sock.send
AttributeError: '_socketobject' object attribute 'send' is read-only


----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2003-04-29 06:19

Message:
Logged In: YES 
user_id=6380

It's ugly because it is an internal implementation detail.

I suggest two changes: 

1) There's no use case for a socket object that has no send,
recv, sendto or recvfrom methods, so you might as well do
the assignments unconditionally.

2) The cloe() method needs to sever all ties to the real
socket object, by setting the 4 new slots to None.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=729293&group_id=5470