diff options
author | Raymond Hettinger <python@rcn.com> | 2003-02-09 06:40:58 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2003-02-09 06:40:58 (GMT) |
commit | 60eca9331a1c2594b1331678d715e6177386c3a4 (patch) | |
tree | fe68e9debd8adce5a689842d2d465d892a20b7ea /Lib/sets.py | |
parent | cb3319f61e94af8794a51f51730dce4a9d512af3 (diff) | |
download | cpython-60eca9331a1c2594b1331678d715e6177386c3a4.zip cpython-60eca9331a1c2594b1331678d715e6177386c3a4.tar.gz cpython-60eca9331a1c2594b1331678d715e6177386c3a4.tar.bz2 |
C Code:
* Removed the ifilter flag wart by splitting it into two simpler functions.
* Fixed comment tabbing in C code.
* Factored module start-up code into a loop.
Documentation:
* Re-wrote introduction.
* Addede examples for quantifiers.
* Simplified python equivalent for islice().
* Documented split of ifilter().
Sets.py:
* Replace old ifilter() usage with new.
Diffstat (limited to 'Lib/sets.py')
-rw-r--r-- | Lib/sets.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/sets.py b/Lib/sets.py index 4f55515..9604249 100644 --- a/Lib/sets.py +++ b/Lib/sets.py @@ -57,7 +57,7 @@ what's tested is actually `z in y'. __all__ = ['BaseSet', 'Set', 'ImmutableSet'] -from itertools import ifilter +from itertools import ifilter, ifilterfalse class BaseSet(object): """Common base class for mutable and immutable sets.""" @@ -204,9 +204,9 @@ class BaseSet(object): value = True selfdata = self._data otherdata = other._data - for elt in ifilter(otherdata.has_key, selfdata, True): + for elt in ifilterfalse(otherdata.has_key, selfdata): data[elt] = value - for elt in ifilter(selfdata.has_key, otherdata, True): + for elt in ifilterfalse(selfdata.has_key, otherdata): data[elt] = value return result @@ -227,7 +227,7 @@ class BaseSet(object): result = self.__class__() data = result._data value = True - for elt in ifilter(other._data.has_key, self, True): + for elt in ifilterfalse(other._data.has_key, self): data[elt] = value return result @@ -260,7 +260,7 @@ class BaseSet(object): self._binary_sanity_check(other) if len(self) > len(other): # Fast check for obvious cases return False - for elt in ifilter(other._data.has_key, self, True): + for elt in ifilterfalse(other._data.has_key, self): return False return True @@ -269,7 +269,7 @@ class BaseSet(object): self._binary_sanity_check(other) if len(self) < len(other): # Fast check for obvious cases return False - for elt in ifilter(self._data.has_key, other, True): + for elt in ifilterfalse(self._data.has_key, other): return False return True |