Message224666
OK, I think I see what you mean:
$ ./python -m timeit -s "import socket; s =
socket.socket(socket.AF_INET, socket.SOCK_DGRAM)" "s.sendto(b'hello',
('127.0.0.1', 4242))"10000 loops, best of 3: 44.7 usec per loop
$ ./python -m timeit -s "import socket; s =
socket.socket(socket.AF_INET, socket.SOCK_DGRAM)" "s.sendto(b'hello',
(b'127.0.0.1', 4242))"
10000 loops, best of 3: 23.7 usec per loop
That's really surprising, especially since gethostbyname() and
getaddrinfo() seem to return strings:
$ ./python -m timeit -s "import socket; s =
socket.socket(socket.AF_INET, socket.SOCK_DGRAM);
addr=socket.gethostbyname('127.0.0.1')" "s.sendto(b'hello', (addr,
4242))"
$ ./python -c "import socket; print(type(socket.gethostbyname('127.0.0.1')))"
<class 'str'> |
|
Date |
User |
Action |
Args |
2014-08-03 22:22:19 | neologix | set | recipients:
+ neologix, loewis, pitrou, vstinner |
2014-08-03 22:22:19 | neologix | link | issue22127 messages |
2014-08-03 22:22:19 | neologix | create | |
|