diff -r edf669b13482 Lib/ipaddress.py --- a/Lib/ipaddress.py Tue Dec 23 16:28:28 2014 +0200 +++ b/Lib/ipaddress.py Fri Dec 26 18:45:42 2014 +0200 @@ -387,6 +387,7 @@ class _TotalOrderingMixin: # __lt__ and __eq__ # We avoid functools.total_ordering because it doesn't handle # NotImplemented correctly yet (http://bugs.python.org/issue10042) + __slots__ = () def __eq__(self, other): raise NotImplementedError def __ne__(self, other): @@ -419,6 +420,8 @@ class _IPAddressBase(_TotalOrderingMixin """The mother class.""" + __slots__ = () + @property def exploded(self): """Return the longhand version of the IP address as a string.""" @@ -572,6 +575,8 @@ class _BaseAddress(_IPAddressBase): used by single IP addresses. """ + __slots__ = () + def __init__(self, address): if (not isinstance(address, bytes) and '/' in str(address)): @@ -1083,6 +1088,8 @@ class _BaseV4: """ + __slots__ = () + _version = 4 # Equivalent to 255.255.255.255 or 32 bits of 1's. _ALL_ONES = (2**IPV4LENGTH) - 1 _DECIMAL_DIGITS = frozenset('0123456789') @@ -1095,9 +1102,6 @@ class _BaseV4: # when constructed (see _make_netmask()). _netmask_cache = {} - def __init__(self, address): - self._version = 4 - def _explode_shorthand_ip_string(self): return str(self) @@ -1275,6 +1279,9 @@ class IPv4Address(_BaseV4, _BaseAddress) """Represent and manipulate single IPv4 Addresses.""" + __slots__ = ('_ip',) + __dict__ = None + def __init__(self, address): """ @@ -1292,7 +1299,6 @@ class IPv4Address(_BaseV4, _BaseAddress) """ _BaseAddress.__init__(self, address) - _BaseV4.__init__(self, address) # Efficient constructor from integer. if isinstance(address, int): @@ -1515,7 +1521,6 @@ class IPv4Network(_BaseV4, _BaseNetwork) """ - _BaseV4.__init__(self, address) _BaseNetwork.__init__(self, address) # Constructing from a packed address or integer @@ -1619,6 +1624,8 @@ class _BaseV6: """ + __slots__ = () + _version = 6 _ALL_ONES = (2**IPV6LENGTH) - 1 _HEXTET_COUNT = 8 _HEX_DIGITS = frozenset('0123456789ABCDEFabcdef') @@ -1628,9 +1635,6 @@ class _BaseV6: # when constructed (see _make_netmask()). _netmask_cache = {} - def __init__(self, address): - self._version = 6 - @classmethod def _make_netmask(cls, arg): """Make a (netmask, prefix_len) tuple from the given argument. @@ -1899,6 +1903,8 @@ class IPv6Address(_BaseV6, _BaseAddress) """Represent and manipulate single IPv6 Addresses.""" + __slots__ = ('_ip',) + def __init__(self, address): """Instantiate a new IPv6 address object. @@ -1917,7 +1923,6 @@ class IPv6Address(_BaseV6, _BaseAddress) """ _BaseAddress.__init__(self, address) - _BaseV6.__init__(self, address) # Efficient constructor from integer. if isinstance(address, int): @@ -2206,7 +2211,6 @@ class IPv6Network(_BaseV6, _BaseNetwork) supplied. """ - _BaseV6.__init__(self, address) _BaseNetwork.__init__(self, address) # Efficient constructor from integer or packed address