From 1f937d957850244f595e17444ade590f3e6f9f22 Mon Sep 17 00:00:00 2001 From: Aleksandr Balezin Date: Wed, 24 May 2017 13:47:16 +0300 Subject: [PATCH 1/2] bpo-25430: performance improvements make a compare in bit-operation manner --- Lib/ipaddress.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py index 70746f8de85c09..5d88095356d73e 100644 --- a/Lib/ipaddress.py +++ b/Lib/ipaddress.py @@ -677,8 +677,7 @@ def __contains__(self, other): # 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.""" From 04bbdc1166fb66396e363d7cc554a1ccb0c6e2b1 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" Date: Mon, 15 Apr 2019 12:22:10 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NEWS.d/next/Library/2019-04-15-12-22-09.bpo-25430.7_8kqc.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2019-04-15-12-22-09.bpo-25430.7_8kqc.rst diff --git a/Misc/NEWS.d/next/Library/2019-04-15-12-22-09.bpo-25430.7_8kqc.rst b/Misc/NEWS.d/next/Library/2019-04-15-12-22-09.bpo-25430.7_8kqc.rst new file mode 100644 index 00000000000000..922bdef56ec31e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-04-15-12-22-09.bpo-25430.7_8kqc.rst @@ -0,0 +1 @@ +improve performance of ``IPNetwork.__contains__()`` \ No newline at end of file