Currently ipaddress address_exclude does a kind of recursive call checking if the exclude ip is contained within the subnet to be split. This ends up checking a lot of times when it is a bit easier to exclude things.
IPs in ipaddress are treated as integers behind the scenes. You can even construct an IP address from an integer
Given this you can consider a network address (10.0.0.0/8) as a range (167772160, 184549375). If you wanted to exclude an IP you can just remove the integer or range of integers. It ends up being much quicker.
(Surprisingly) in the ipaddress module there is no IPv4Range class. Do you suggest to call ipaddress.summarize_address_range() on the two resulting ranges to get a list of IPv4Network objects?
In the end self._ip should be an integer. I am happy to test this out but am not sure what to test it on. I have a desktop and linux server. I believe Solaris would be something that is little endian. Would a VM of solaris be possible and preserve this?
@vbrozik That is what I was thinking. Would be happy to contribute more to ipaddress as my new project makes extensive use of it. I am however new to contributing to the standard library and would need guidance on how to make my first submission. Would it be as simple as a PR to the github repos above?(I cannot put more than two links, weird) If this was changed, would it only make it into later version of python or would it be available in 3.7? I imagine not.
Seems like this should be a pretty straight forward improvement. In general I would like to see multiple improvements to the ipaddress.py module beyond this. Should I create PRs on Github or is there some other location?