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

Method cmp

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

Source from the content-addressed store, hash-verified

693
694impl Comparable for PyBytes {
695 fn cmp(
696 zelf: &Py<Self>,
697 other: &PyObject,
698 op: PyComparisonOp,
699 vm: &VirtualMachine,
700 ) -> PyResult<PyComparisonValue> {
701 Ok(if let Some(res) = op.identical_optimization(zelf, other) {
702 res.into()
703 } else if other.fast_isinstance(vm.ctx.types.memoryview_type)
704 && op != PyComparisonOp::Eq
705 && op != PyComparisonOp::Ne
706 {
707 return Err(vm.new_type_error(format!(
708 "'{}' not supported between instances of '{}' and '{}'",
709 op.operator_token(),
710 zelf.class().name(),
711 other.class().name()
712 )));
713 } else {
714 zelf.inner.cmp(other, op, vm)
715 })
716 }
717}
718
719impl Iterable for PyBytes {

Callers

nothing calls this directly

Calls 3

fast_isinstanceMethod · 0.80
ErrClass · 0.50

Tested by

no test coverage detected