| 415 | #[pyclass] |
| 416 | impl Py<PyDict> { |
| 417 | fn inner_cmp( |
| 418 | &self, |
| 419 | other: &Self, |
| 420 | op: PyComparisonOp, |
| 421 | item: bool, |
| 422 | vm: &VirtualMachine, |
| 423 | ) -> PyResult<PyComparisonValue> { |
| 424 | if op == PyComparisonOp::Ne { |
| 425 | return Self::inner_cmp(self, other, PyComparisonOp::Eq, item, vm) |
| 426 | .map(|x| x.map(|eq| !eq)); |
| 427 | } |
| 428 | if !op.eval_ord(self.__len__().cmp(&other.__len__())) { |
| 429 | return Ok(Implemented(false)); |
| 430 | } |
| 431 | let (superset, subset) = if self.__len__() < other.__len__() { |
| 432 | (other, self) |
| 433 | } else { |
| 434 | (self, other) |
| 435 | }; |
| 436 | for (k, v1) in subset { |
| 437 | match superset.get_item_opt(&*k, vm)? { |
| 438 | Some(v2) => { |
| 439 | if v1.is(&v2) { |
| 440 | continue; |
| 441 | } |
| 442 | if item && !vm.bool_eq(&v1, &v2)? { |
| 443 | return Ok(Implemented(false)); |
| 444 | } |
| 445 | } |
| 446 | None => { |
| 447 | return Ok(Implemented(false)); |
| 448 | } |
| 449 | } |
| 450 | } |
| 451 | Ok(Implemented(true)) |
| 452 | } |
| 453 | |
| 454 | #[cfg_attr(feature = "flame-it", flame("PyDictRef"))] |
| 455 | fn __getitem__(&self, key: PyObjectRef, vm: &VirtualMachine) -> PyResult { |