MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / rich_compare

Method rich_compare

src/objectprotocol.rs:157–172  ·  view source on GitHub ↗

Compares two Python objects. Depending on the value of `compare_op`, equivalent to one of the following Python expressions: CompareOp::Eq: `self == other` CompareOp::Ne: `self != other` CompareOp::Lt: `self < other` CompareOp::Le: `self <= other` CompareOp::Gt: `self > other` CompareOp::Ge: `self >= other`

(
        &self,
        py: Python,
        other: O,
        compare_op: crate::CompareOp,
    )

Source from the content-addressed store, hash-verified

155 /// * CompareOp::Gt: `self > other`
156 /// * CompareOp::Ge: `self >= other`
157 fn rich_compare<O>(
158 &self,
159 py: Python,
160 other: O,
161 compare_op: crate::CompareOp,
162 ) -> PyResult<PyObject>
163 where
164 O: ToPyObject,
165 {
166 other.with_borrowed_ptr(py, |other| unsafe {
167 err::result_cast_from_owned_ptr(
168 py,
169 ffi::PyObject_RichCompare(self.as_ptr(), other, compare_op as libc::c_int),
170 )
171 })
172 }
173
174 /// Compute the string representation of self.
175 /// This is equivalent to the Python expression 'repr(self)'.

Callers

nothing calls this directly

Implementers 1

objectprotocol.rssrc/objectprotocol.rs

Calls 3

with_borrowed_ptrMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected