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

Method __reduce_ex__

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

Source from the content-addressed store, hash-verified

1124
1125 #[pymethod]
1126 fn __reduce_ex__(
1127 zelf: &Py<Self>,
1128 proto: usize,
1129 vm: &VirtualMachine,
1130 ) -> PyResult<(PyObjectRef, PyTupleRef, Option<PyDictRef>)> {
1131 if proto < 3 {
1132 return Self::__reduce__(zelf, vm);
1133 }
1134 let array = zelf.read();
1135 let cls = zelf.class().to_owned();
1136 let typecode = vm.ctx.new_str(array.typecode_str());
1137 let bytes = vm.ctx.new_bytes(array.get_bytes().to_vec());
1138 let code = MachineFormatCode::from_typecode(array.typecode()).unwrap();
1139 let code = PyInt::from(u8::from(code)).into_pyobject(vm);
1140 let module = vm.import("array", 0)?;
1141 let func = module.get_attr("_array_reconstructor", vm)?;
1142 Ok((
1143 func,
1144 vm.new_tuple((cls, typecode, code, bytes)),
1145 zelf.as_object().dict(),
1146 ))
1147 }
1148
1149 #[pymethod]
1150 fn __reduce__(

Callers

nothing calls this directly

Calls 15

to_vecMethod · 0.80
typecodeMethod · 0.80
readMethod · 0.45
to_ownedMethod · 0.45
classMethod · 0.45
new_strMethod · 0.45
new_bytesMethod · 0.45
get_bytesMethod · 0.45
unwrapMethod · 0.45
into_pyobjectMethod · 0.45
importMethod · 0.45
get_attrMethod · 0.45

Tested by

no test coverage detected