Charles-François Natali added the comment:
Here's an updated patch with new tests.
It passes the regression test, and yields noticable performance improvements
for IPv6:
before:
$ ./python -m timeit -s "import socket; s = socket.socket(socket.AF_INET,
socket.SOCK_DGRAM); DATA = b'hello'" "s.sendto(DATA, ('127.0.0.1', 4242)) "
10000 loops, best of 3: 28 usec per loop
$ ./python -m timeit -s "import socket; s = socket.socket(socket.AF_INET6,
socket.SOCK_DGRAM); DATA = b'hello'" "s.sendto(DATA, ('::1', 4242)) "
10000 loops, best of 3: 59.1 usec per loop
after:
$ ./python -m timeit -s "import socket; s = socket.socket(socket.AF_INET,
socket.SOCK_DGRAM); DATA = b'hello'" "s.sendto(DATA, ('127.0.0.1', 4242)) "
10000 loops, best of 3: 24.8 usec per loop
$ ./python -m timeit -s "import socket; s = socket.socket(socket.AF_INET6,
socket.SOCK_DGRAM); DATA = b'hello'" "s.sendto(DATA, ('::1', 4242)) "
10000 loops, best of 3: 26.7 usec per loop
Note that the tests aren't as good as I'd like them to, because apparently some
systems (e.g. Solaris) have broken gethostbyaddr()...
But it's cleaner, more robust and more efficient.
----------
Added file: http://bugs.python.org/file31576/parse_inet-1.diff
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue16201>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com