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

Method cmp

crates/vm/src/bytes_inner.rs:296–309  ·  view source on GitHub ↗
(
        &self,
        other: &PyObject,
        op: PyComparisonOp,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

294 }
295
296 pub fn cmp(
297 &self,
298 other: &PyObject,
299 op: PyComparisonOp,
300 vm: &VirtualMachine,
301 ) -> PyComparisonValue {
302 // TODO: bytes can compare with any object implemented buffer protocol
303 // but not memoryview, and not equal if compare with unicode str(PyStr)
304 PyComparisonValue::from_option(
305 other
306 .try_bytes_like(vm, |other| op.eval_ord(self.elements.as_slice().cmp(other)))
307 .ok(),
308 )
309 }
310
311 pub fn hash(&self, vm: &VirtualMachine) -> hash::PyHash {
312 vm.state.hash_secret.hash_bytes(&self.elements)

Callers 13

compile_fileFunction · 0.45
test_matchingMethod · 0.45
test_differentMethod · 0.45
test_cache_clearMethod · 0.45
test_recompilationMethod · 0.45
test_importMethod · 0.45
complete_optMethod · 0.45
compare_pathsFunction · 0.45
richcompareMethod · 0.45
execute_instructionMethod · 0.45
unpack_fastMethod · 0.45
execute_compareMethod · 0.45

Calls 4

okMethod · 0.80
try_bytes_likeMethod · 0.80
eval_ordMethod · 0.80
as_sliceMethod · 0.45

Tested by 5

test_matchingMethod · 0.36
test_differentMethod · 0.36
test_cache_clearMethod · 0.36
test_recompilationMethod · 0.36
test_importMethod · 0.36