mirror of
https://github.com/python/cpython.git
synced 2025-10-19 21:28:02 +00:00
bpo-25430: improve performance of IPNetwork.__contains__ (GH-1785)
make a compare in bit-operation manner.
This commit is contained in:
parent
b0a2c0fa83
commit
3bbcc92577
2 changed files with 2 additions and 2 deletions
|
@ -697,8 +697,7 @@ class _BaseNetwork(_IPAddressBase):
|
||||||
# dealing with another address
|
# dealing with another address
|
||||||
else:
|
else:
|
||||||
# address
|
# address
|
||||||
return (int(self.network_address) <= int(other._ip) <=
|
return other._ip & self.netmask._ip == self.network_address._ip
|
||||||
int(self.broadcast_address))
|
|
||||||
|
|
||||||
def overlaps(self, other):
|
def overlaps(self, other):
|
||||||
"""Tell if self is partly contained in other."""
|
"""Tell if self is partly contained in other."""
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
improve performance of ``IPNetwork.__contains__()``
|
Loading…
Add table
Add a link
Reference in a new issue