Author Sanjay
Recipients Sanjay
Date 2019-10-01.11:43:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1569930223.76.0.865877463422.issue38335@roundup.psfhosted.org>
In-reply-to
Content
the current implementation of overlaps function tests either network or broadcast address is in other but
we can skip checking broadcast address is in other because we anyway check if other.network_address in self 

without loss of generality if we assume self has smaller prefixlen than other then when self.broadcast_address in other then other.network_address *SHOULD* be in self but the reverse is not true

so my first patch was to make the function logic simply do
`self.network_address in other or other.network_address in self`

but the current PR does a different change. We have introduced two new functions subnet_of and supernet_of

for two networks A, B there are only three possibilities 
1. they don't overlap
2. A is subnet of B
3. B is subnet of A

so we can reuse the existing function and just do
`return self.subnet_of(other) or self.supernet_of(other)`
the only thing is while overlaps() function returns false when we try to compare with a network or with diff version the other throws exception so I added a typecheck in the beginning.

P.S the docstring is slightly convoluted for newcomers, based on the three possibilities it should say "Tell if self is supernet or subnet of other" because "partly contained" can also mean two ranges intersect which can never happen to network prefixes. I have not made that change but can make it.

There are also some other issues I want to address but I want to do one at a time.
History
Date User Action Args
2019-10-01 11:43:43Sanjaysetrecipients: + Sanjay
2019-10-01 11:43:43Sanjaysetmessageid: <1569930223.76.0.865877463422.issue38335@roundup.psfhosted.org>
2019-10-01 11:43:43Sanjaylinkissue38335 messages
2019-10-01 11:43:43Sanjaycreate