Markus added the comment:

My initial patch was wrong wrt. _find_address_range.
It did not loop over equal addresses.
Thats why performance with many equal addresses was degraded when dropping the 
set().

Here is a patch to fix _find_address_range, drop the set, and improve 
performance again.

python3 -m timeit -s "import bipaddress; ips = 
[bipaddress.ip_address('2001:db8::1000') for i in range(1000)]" -- 
"bipaddress.collapse_addresses(ips)"
1000 loops, best of 3: 1.76 msec per loop

python3 -m timeit -s "import aipaddress; ips = 
[aipaddress.ip_address('2001:db8::1000') for i in range(1000)]" -- 
"aipaddress.collapse_addresses(ips)"
1000 loops, best of 3: 1.32 msec per loop

----------
Added file: http://bugs.python.org/file37794/ipaddress_faster_collapse4.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23266>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to