Gave issubet() and issuperset() major speed boosts. That's it for now!
Someone else may want to tackle the mutating operations similarly.
This commit is contained in:
parent
b8940393e9
commit
cd06eeb20c
|
@ -259,8 +259,9 @@ class BaseSet(object):
|
||||||
self._binary_sanity_check(other)
|
self._binary_sanity_check(other)
|
||||||
if len(self) > len(other): # Fast check for obvious cases
|
if len(self) > len(other): # Fast check for obvious cases
|
||||||
return False
|
return False
|
||||||
|
otherdata = other._data
|
||||||
for elt in self:
|
for elt in self:
|
||||||
if elt not in other:
|
if elt not in otherdata:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -269,8 +270,9 @@ class BaseSet(object):
|
||||||
self._binary_sanity_check(other)
|
self._binary_sanity_check(other)
|
||||||
if len(self) < len(other): # Fast check for obvious cases
|
if len(self) < len(other): # Fast check for obvious cases
|
||||||
return False
|
return False
|
||||||
|
selfdata = self._data
|
||||||
for elt in other:
|
for elt in other:
|
||||||
if elt not in self:
|
if elt not in selfdata:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue