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

Method setitem_by_idx

crates/vm/src/builtins/memory.rs:171–182  ·  view source on GitHub ↗
(&self, i: isize, value: PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

169 }
170
171 fn setitem_by_idx(&self, i: isize, value: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {
172 if self.desc.ndim() != 1 {
173 return Err(vm.new_not_implemented_error("sub-views are not implemented"));
174 }
175 let (shape, stride, suboffset) = self.desc.dim_desc[0];
176 let index = i
177 .wrapped_at(shape)
178 .ok_or_else(|| vm.new_index_error("index out of range"))?;
179 let index = index as isize * stride + suboffset;
180 let pos = (index + self.start as isize) as usize;
181 self.pack_single(pos, value, vm)
182 }
183
184 fn setitem_by_multi_idx(
185 &self,

Callers 1

__setitem__Method · 0.80

Calls 5

ok_or_elseMethod · 0.80
wrapped_atMethod · 0.80
pack_singleMethod · 0.80
ErrClass · 0.50
ndimMethod · 0.45

Tested by

no test coverage detected