summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG18
-rw-r--r--netaddr/ip/sets.py9
2 files changed, 23 insertions, 4 deletions
diff --git a/CHANGELOG b/CHANGELOG
index dd6be38..ec182ab 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,22 @@
---------------
+Release: 0.7.15
+---------------
+Date: ?????????
+
+^^^^^^^^^^^^^^^^^^^^
+Changes since 0.7.14
+^^^^^^^^^^^^^^^^^^^^
+
+* Fix slowness in IPSet.__contains__. Thanks to novas0x2a for noticing.
+
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Specific bug fixes addressed in this release
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+FIXED Issue 94: https://github.com/drkjam/netaddr/issues/94
+ - IPSet.__contains__ is about 40 times slower than the equivalent IPRange
+
+---------------
Release: 0.7.14
---------------
Date: 31st Mar 2015
diff --git a/netaddr/ip/sets.py b/netaddr/ip/sets.py
index 204ffd2..70f44cf 100644
--- a/netaddr/ip/sets.py
+++ b/netaddr/ip/sets.py
@@ -231,15 +231,16 @@ class IPSet(object):
:return: ``True`` if IP address or subnet is a member of this IP set.
"""
- ip = IPNetwork(ip)
# Iterating over self._cidrs is an O(n) operation: 1000 items in
# self._cidrs would mean 1000 loops. Iterating over all possible
# supernets loops at most 32 times for IPv4 or 128 times for IPv6,
# no matter how many CIDRs this object contains.
- if ip in self._cidrs:
+ supernet = IPNetwork(ip)
+ if supernet in self._cidrs:
return True
- for cidr in ip.supernet():
- if cidr in self._cidrs:
+ while supernet._prefixlen:
+ supernet._prefixlen -= 1
+ if supernet in self._cidrs:
return True
return False