-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assorted ipaddress performance improvements #65686
Comments
Now that issue bpo-16531 has been committed, it becomes possible to make some operations faster. Attached patch makes summarize_address_range() ~2x faster and Network.subnets() ~4x faster. |
Alternative implementations of _count_righthand_zero_bits(): def _count_righthand_zero_bits(number, bits):
if not number:
return bits
return (~number & (number-1)).bit_length() or def _count_righthand_zero_bits(number, bits):
if not number:
return bits
return (~(number | -number)).bit_length() |
Good point, this is a much faster implementation. Updated patch (and fixed the implementation to not return more than |
Looks as second alternative is few percents faster then first one. |
I find logical operations on negative numbers confusing in Python, so I'd rather stick with the first implementation. |
New changeset 2711677cf874 by Antoine Pitrou in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: