Skip to content

Commit 178c061

Browse files
committed
gh-134012: Simplify IPv*Interface.__hash__()
The value of `self._ip` and `int(self.network.network_address)` will always be the identical. Therefore, it's unnecessary to include `int(self.network.network_address)` in the tuple used to compute the hash.
1 parent 0afbd4e commit 178c061

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Lib/ipaddress.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ def __lt__(self, other):
14561456
return False
14571457

14581458
def __hash__(self):
1459-
return hash((self._ip, self._prefixlen, int(self.network.network_address)))
1459+
return hash((self._ip, self._prefixlen))
14601460

14611461
__reduce__ = _IPAddressBase.__reduce__
14621462

@@ -2233,7 +2233,7 @@ def __lt__(self, other):
22332233
return False
22342234

22352235
def __hash__(self):
2236-
return hash((self._ip, self._prefixlen, int(self.network.network_address)))
2236+
return hash((self._ip, self._prefixlen))
22372237

22382238
__reduce__ = _IPAddressBase.__reduce__
22392239

0 commit comments

Comments
 (0)