bpo-30296 Remove unnecessary tuples, lists, sets, and dicts (#1489)

* Replaced list(<generator expression>) with list comprehension
* Replaced dict(<generator expression>) with dict comprehension
* Replaced set(<list literal>) with set literal
* Replaced builtin func(<list comprehension>) with func(<generator
  expression>) when supported (e.g. any(), all(), tuple(), min(), &
  max())
This commit is contained in:
Jon Dufresne 2017-05-18 07:35:54 -07:00 committed by Raymond Hettinger
parent 906f5330b9
commit 3972628de3
19 changed files with 32 additions and 39 deletions

View file

@ -157,19 +157,19 @@ class WeakSet:
__le__ = issubset
def __lt__(self, other):
return self.data < set(ref(item) for item in other)
return self.data < set(map(ref, other))
def issuperset(self, other):
return self.data.issuperset(ref(item) for item in other)
__ge__ = issuperset
def __gt__(self, other):
return self.data > set(ref(item) for item in other)
return self.data > set(map(ref, other))
def __eq__(self, other):
if not isinstance(other, self.__class__):
return NotImplemented
return self.data == set(ref(item) for item in other)
return self.data == set(map(ref, other))
def symmetric_difference(self, other):
newset = self.copy()