aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgescheit <gescheit12@gmail.com>2019-04-30 10:54:30 +0300
committerInada Naoki <songofacandy@gmail.com>2019-04-30 16:54:30 +0900
commit3bbcc92577f8e616bc94c679040043bacd00ebf1 (patch)
treec010916e6f1cb8ca7872b0b325193dcaf7eaef42 /Lib/ipaddress.py
parentbpo-36018: Test idempotence. Test two methods against one-another. (GH-13021) (diff)
downloadcpython-3bbcc92577f8e616bc94c679040043bacd00ebf1.tar.gz
cpython-3bbcc92577f8e616bc94c679040043bacd00ebf1.tar.bz2
cpython-3bbcc92577f8e616bc94c679040043bacd00ebf1.zip
bpo-25430: improve performance of IPNetwork.__contains__ (GH-1785)
make a compare in bit-operation manner.
Diffstat (limited to 'Lib/ipaddress.py')
-rw-r--r--Lib/ipaddress.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py
index 909a55de4f1..662d7373890 100644
--- a/Lib/ipaddress.py
+++ b/Lib/ipaddress.py
@@ -697,8 +697,7 @@ class _BaseNetwork(_IPAddressBase):
# dealing with another address
else:
# address
- return (int(self.network_address) <= int(other._ip) <=
- int(self.broadcast_address))
+ return other._ip & self.netmask._ip == self.network_address._ip
def overlaps(self, other):
"""Tell if self is partly contained in other."""