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

Method __reduce__

crates/stdlib/src/array.rs:1150–1169  ·  view source on GitHub ↗
(
            zelf: &Py<Self>,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

1148
1149 #[pymethod]
1150 fn __reduce__(
1151 zelf: &Py<Self>,
1152 vm: &VirtualMachine,
1153 ) -> PyResult<(PyObjectRef, PyTupleRef, Option<PyDictRef>)> {
1154 let array = zelf.read();
1155 let cls = zelf.class().to_owned();
1156 let typecode = vm.ctx.new_str(array.typecode_str());
1157 let values = if array.typecode() == 'u' {
1158 let s = Self::_wchar_bytes_to_string(array.get_bytes(), array.itemsize(), vm)?;
1159 s.code_points().map(|x| x.to_pyobject(vm)).collect()
1160 } else {
1161 array.get_objects(vm)
1162 };
1163 let values = vm.ctx.new_list(values);
1164 Ok((
1165 cls.into(),
1166 vm.new_tuple((typecode, values)),
1167 zelf.as_object().dict(),
1168 ))
1169 }
1170
1171 fn __contains__(&self, value: PyObjectRef, vm: &VirtualMachine) -> bool {
1172 let array = self.array.read();

Callers

nothing calls this directly

Calls 15

builtins_iterFunction · 0.85
typecodeMethod · 0.80
collectMethod · 0.80
code_pointsMethod · 0.80
get_objectsMethod · 0.80
new_listMethod · 0.80
readMethod · 0.45
to_ownedMethod · 0.45
classMethod · 0.45
new_strMethod · 0.45
get_bytesMethod · 0.45
itemsizeMethod · 0.45

Tested by

no test coverage detected