Feb-13-2019, 09:49 AM
Hello,
I'm trying to create a socket, then connect to the same server until I can't make any connection from my PC and I face a problem : my program is WAY faster with Python 2.7 than with Python 3.7.
Here a minimal example:
Ouput with Python 3.7 client side and Python 3.7 server side:
16298
32.764869928359985
Ouput with Python 2.7 client side and Python 3.7 server side:
16297
1.86599993706
OS: Windows 10
I'm trying to create a socket, then connect to the same server until I can't make any connection from my PC and I face a problem : my program is WAY faster with Python 2.7 than with Python 3.7.
Here a minimal example:
# client.py
import time
import socket
begin = time.time()
socket_list = []
while True:
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(1)
s.connect(("127.0.0.1", 65432))
socket_list.append(s)
except:
print(len(socket_list))
print(time.time() - begin)
for sock in socket_list:
sock.close()
break# server.py
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("127.0.0.1", 65432))
s.listen()
while True:
s.accept() Ouput with Python 3.7 client side and Python 3.7 server side:
16298
32.764869928359985
Ouput with Python 2.7 client side and Python 3.7 server side:
16297
1.86599993706
OS: Windows 10
