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

Method cmp

crates/vm/src/builtins/dict.rs:1208–1239  ·  view source on GitHub ↗
(
        zelf: &Py<Self>,
        other: &PyObject,
        op: PyComparisonOp,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

1206 }
1207
1208 fn cmp(
1209 zelf: &Py<Self>,
1210 other: &PyObject,
1211 op: PyComparisonOp,
1212 vm: &VirtualMachine,
1213 ) -> PyResult<PyComparisonValue> {
1214 match_class!(match other {
1215 ref dictview @ Self => {
1216 return zelf.dict().inner_cmp(
1217 dictview.dict(),
1218 op,
1219 !zelf.class().is(vm.ctx.types.dict_keys_type),
1220 vm,
1221 );
1222 }
1223 ref _set @ PySet => {
1224 let inner = Self::to_set(zelf.to_owned(), vm)?;
1225 let zelf_set = PySet { inner }.into_pyobject(vm);
1226 return PySet::cmp(zelf_set.downcast_ref().unwrap(), other, op, vm);
1227 }
1228 ref _dictitems @ PyDictItems => {}
1229 ref _dictkeys @ PyDictKeys => {}
1230 _ => {
1231 return Ok(NotImplemented);
1232 }
1233 });
1234 let lhs: Vec<PyObjectRef> = zelf.as_object().to_owned().try_into_value(vm)?;
1235 let rhs: Vec<PyObjectRef> = other.to_owned().try_into_value(vm)?;
1236 lhs.iter()
1237 .richcompare(rhs.iter(), op, vm)
1238 .map(PyComparisonValue::Implemented)
1239 }
1240
1241 #[pymethod]
1242 fn isdisjoint(zelf: PyRef<Self>, other: ArgIterable, vm: &VirtualMachine) -> PyResult<bool> {

Callers

nothing calls this directly

Implementers 1

dict.rscrates/vm/src/builtins/dict.rs

Calls 6

try_into_valueMethod · 0.80
richcompareMethod · 0.80
to_ownedMethod · 0.45
as_objectMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected