MCPcopy Index your code
hub / github.com/RustPython/RustPython / inner_cmp

Method inner_cmp

crates/vm/src/builtins/dict.rs:417–452  ·  view source on GitHub ↗
(
        &self,
        other: &Self,
        op: PyComparisonOp,
        item: bool,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

415#[pyclass]
416impl 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 {

Callers 1

cmpMethod · 0.80

Calls 7

eval_ordMethod · 0.80
get_item_optMethod · 0.80
isMethod · 0.80
bool_eqMethod · 0.80
mapMethod · 0.45
cmpMethod · 0.45
__len__Method · 0.45

Tested by

no test coverage detected