Method
cmp
(
zelf: &Py<Self>,
other: &PyObject,
op: PyComparisonOp,
_vm: &VirtualMachine,
)
Source from the content-addressed store, hash-verified
| 84 | // meth_richcompare in CPython |
| 85 | impl Comparable for PyNativeFunction { |
| 86 | fn cmp( |
| 87 | zelf: &Py<Self>, |
| 88 | other: &PyObject, |
| 89 | op: PyComparisonOp, |
| 90 | _vm: &VirtualMachine, |
| 91 | ) -> PyResult<PyComparisonValue> { |
| 92 | op.eq_only(|| { |
| 93 | if let Some(other) = other.downcast_ref::<Self>() { |
| 94 | let eq = match (zelf.zelf.as_ref(), other.zelf.as_ref()) { |
| 95 | (Some(z), Some(o)) => z.is(o), |
| 96 | (None, None) => true, |
| 97 | _ => false, |
| 98 | }; |
| 99 | let eq = eq && core::ptr::eq(zelf.value, other.value); |
| 100 | Ok(eq.into()) |
| 101 | } else { |
| 102 | Ok(PyComparisonValue::NotImplemented) |
| 103 | } |
| 104 | }) |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | // meth_repr in CPython |
Callers
nothing calls this directly
Tested by
no test coverage detected