diff options
author | Tim Peters <tim.peters@gmail.com> | 2002-08-25 20:12:19 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2002-08-25 20:12:19 (GMT) |
commit | cd06eeb20cff9af7d21c87222e1267b80012ce92 (patch) | |
tree | 88443fa6dc17b2f5b6106f8b78f581e6679a7269 | |
parent | b8940393e9be5be09920f28bfea0049e4255354b (diff) | |
download | cpython-cd06eeb20cff9af7d21c87222e1267b80012ce92.zip cpython-cd06eeb20cff9af7d21c87222e1267b80012ce92.tar.gz cpython-cd06eeb20cff9af7d21c87222e1267b80012ce92.tar.bz2 |
Gave issubet() and issuperset() major speed boosts. That's it for now!
Someone else may want to tackle the mutating operations similarly.
-rw-r--r-- | Lib/sets.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/sets.py b/Lib/sets.py index 4665373..e33464b 100644 --- a/Lib/sets.py +++ b/Lib/sets.py @@ -259,8 +259,9 @@ class BaseSet(object): self._binary_sanity_check(other) if len(self) > len(other): # Fast check for obvious cases return False + otherdata = other._data for elt in self: - if elt not in other: + if elt not in otherdata: return False return True @@ -269,8 +270,9 @@ class BaseSet(object): self._binary_sanity_check(other) if len(self) < len(other): # Fast check for obvious cases return False + selfdata = self._data for elt in other: - if elt not in self: + if elt not in selfdata: return False return True |