@@ -1244,7 +1244,6 @@ def is_private(self):
12441244 """
12451245 return (self in IPv4Network ('0.0.0.0/8' ) or
12461246 self in IPv4Network ('10.0.0.0/8' ) or
1247- self in IPv4Network ('100.64.0.0/10' ) or
12481247 self in IPv4Network ('127.0.0.0/8' ) or
12491248 self in IPv4Network ('169.254.0.0/16' ) or
12501249 self in IPv4Network ('172.16.0.0/12' ) or
@@ -1258,17 +1257,6 @@ def is_private(self):
12581257 self in IPv4Network ('240.0.0.0/4' ) or
12591258 self in IPv4Network ('255.255.255.255/32' ))
12601259
1261- @property
1262- def is_global (self ):
1263- """Test if this address is allocated for public networks.
1264-
1265- Returns:
1266- A boolean, True if the address is not reserved per
1267- iana-ipv4-special-registry.
1268-
1269- """
1270- return self in IPv4Network ('100.64.0.0/10' ) or not self .is_private
1271-
12721260
12731261 @property
12741262 def is_multicast (self ):
@@ -1501,6 +1489,21 @@ def __init__(self, address, strict=True):
15011489 if self ._prefixlen == (self ._max_prefixlen - 1 ):
15021490 self .hosts = self .__iter__
15031491
1492+ @property
1493+ @functools .lru_cache ()
1494+ def is_global (self ):
1495+ """Test if this address is allocated for public networks.
1496+
1497+ Returns:
1498+ A boolean, True if the address is not reserved per
1499+ iana-ipv4-special-registry.
1500+
1501+ """
1502+ return (not (self .network_address in IPv4Network ('100.64.0.0/10' ) and
1503+ self .broadcast_address in IPv4Network ('100.64.0.0/10' )) and
1504+ not self .is_private )
1505+
1506+
15041507
15051508class _BaseV6 :
15061509
0 commit comments