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

Method array_eq

crates/stdlib/src/array.rs:1101–1123  ·  view source on GitHub ↗
(&self, other: &Self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1099 }
1100
1101 fn array_eq(&self, other: &Self, vm: &VirtualMachine) -> PyResult<bool> {
1102 // we cannot use zelf.is(other) for shortcut because if we contenting a
1103 // float value NaN we always return False even they are the same object.
1104 if self.__len__() != other.__len__() {
1105 return Ok(false);
1106 }
1107 let array_a = self.read();
1108 let array_b = other.read();
1109
1110 // fast path for same ArrayContentType type
1111 if let Ok(ord) = array_a.cmp(&array_b) {
1112 return Ok(ord == Some(Ordering::Equal));
1113 }
1114
1115 let iter = Iterator::zip(array_a.iter(vm), array_b.iter(vm));
1116
1117 for (a, b) in iter {
1118 if !vm.bool_eq(&*a?, &*b?)? {
1119 return Ok(false);
1120 }
1121 }
1122 Ok(true)
1123 }
1124
1125 #[pymethod]
1126 fn __reduce_ex__(

Callers 1

cmpMethod · 0.80

Calls 6

bool_eqMethod · 0.80
SomeClass · 0.50
__len__Method · 0.45
readMethod · 0.45
cmpMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected