Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions Lib/ipaddress.py
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ class IPv4Address(_BaseV4, _BaseAddress):

"""Represent and manipulate single IPv4 Addresses."""

__slots__ = ('_ip', '__weakref__')
__slots__ = ('_ip', '__weakref__', '__dict__')

def __init__(self, address):

Expand Down Expand Up @@ -1317,8 +1317,7 @@ def is_reserved(self):
"""
return self in self._constants._reserved_network

@property
@functools.lru_cache()
@functools.cached_property
def is_private(self):
"""``True`` if the address is defined as not globally reachable by
iana-ipv4-special-registry_ (for IPv4) or iana-ipv6-special-registry_
Expand All @@ -1339,8 +1338,7 @@ def is_private(self):
and all(self not in net for net in self._constants._private_networks_exceptions)
)

@property
@functools.lru_cache()
@functools.cached_property
def is_global(self):
"""``True`` if the address is defined as globally reachable by
iana-ipv4-special-registry_ (for IPv4) or iana-ipv6-special-registry_
Expand Down Expand Up @@ -1548,8 +1546,7 @@ def __init__(self, address, strict=True):
elif self._prefixlen == (self.max_prefixlen):
self.hosts = lambda: iter((IPv4Address(addr),))

@property
@functools.lru_cache()
@functools.cached_property
def is_global(self):
"""Test if this address is allocated for public networks.

Expand Down Expand Up @@ -1912,7 +1909,7 @@ class IPv6Address(_BaseV6, _BaseAddress):

"""Represent and manipulate single IPv6 Addresses."""

__slots__ = ('_ip', '_scope_id', '__weakref__')
__slots__ = ('_ip', '_scope_id', '__weakref__', '__dict__')

def __init__(self, address):
"""Instantiate a new IPv6 address object.
Expand Down Expand Up @@ -2085,8 +2082,7 @@ def is_site_local(self):
"""
return self in self._constants._sitelocal_network

@property
@functools.lru_cache()
@functools.cached_property
def is_private(self):
"""``True`` if the address is defined as not globally reachable by
iana-ipv4-special-registry_ (for IPv4) or iana-ipv6-special-registry_
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blurb new "Fix memory leak in ipaddress properties by switching from functools.lru_cache to functools.cached_property."
Loading