| 223 | } |
| 224 | |
| 225 | fn compare(&self, other: &Self, op: PyComparisonOp, vm: &VirtualMachine) -> PyResult<bool> { |
| 226 | if op == PyComparisonOp::Ne { |
| 227 | return self.compare(other, PyComparisonOp::Eq, vm).map(|eq| !eq); |
| 228 | } |
| 229 | if !op.eval_ord(self.len().cmp(&other.len())) { |
| 230 | return Ok(false); |
| 231 | } |
| 232 | |
| 233 | let (superset, subset) = match op { |
| 234 | PyComparisonOp::Lt | PyComparisonOp::Le => (other, self), |
| 235 | _ => (self, other), |
| 236 | }; |
| 237 | |
| 238 | for key in subset.elements() { |
| 239 | if !superset.contains(&key, vm)? { |
| 240 | return Ok(false); |
| 241 | } |
| 242 | } |
| 243 | Ok(true) |
| 244 | } |
| 245 | |
| 246 | pub(super) fn union(&self, other: ArgIterable, vm: &VirtualMachine) -> PyResult<Self> { |
| 247 | let set = self.clone(); |