Browse Source

bpo-25430: improve performance of IPNetwork.__contains__ (GH-1785)

make a compare in bit-operation manner.
pull/4476/merge
gescheit 7 years ago
committed by Inada Naoki
parent
commit
3bbcc92577
  1. 3
      Lib/ipaddress.py
  2. 1
      Misc/NEWS.d/next/Library/2019-04-15-12-22-09.bpo-25430.7_8kqc.rst

3
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."""

1
Misc/NEWS.d/next/Library/2019-04-15-12-22-09.bpo-25430.7_8kqc.rst

@ -0,0 +1 @@
improve performance of ``IPNetwork.__contains__()``
Loading…
Cancel
Save