@@ -114,13 +114,7 @@ def elements(self):
114114 )
115115
116116 def __contains__ (self , item ):
117- try :
118- count = self [item ]
119- except KeyError :
120- return False
121- else :
122- assert count >= 1
123- return True
117+ return (self [item ] >= 1 )
124118
125119
126120 def __add__ (self , other ):
@@ -135,7 +129,7 @@ def __add__(self, other):
135129 return NotImplemented
136130 return type (self )(self ._dict_type (
137131 (key , self [key ] + other [key ])
138- for key in set (self ) | self (other ))
132+ for key in set (self ) | set (other ))
139133 )
140134
141135 def __sub__ (self , other ):
@@ -164,7 +158,7 @@ def __or__(self, other):
164158 return NotImplemented
165159 return type (self )(self ._dict_type (
166160 (key , max (self [key ], other [key ]))
167- for key in set (self ) | self (other ))
161+ for key in set (self ) | set (other ))
168162 )
169163
170164 def __and__ (self , other ):
@@ -179,7 +173,7 @@ def __and__(self, other):
179173 return NotImplemented
180174 return type (self )(self ._dict_type (
181175 (key , min (self [key ], other [key ]))
182- for key in set (self ) & self (other ))
176+ for key in set (self ) & set (other ))
183177 )
184178
185179
0 commit comments