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

Method unpack_single

crates/vm/src/builtins/memory.rs:207–219  ·  view source on GitHub ↗
(&self, pos: usize, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

205 }
206
207 fn unpack_single(&self, pos: usize, vm: &VirtualMachine) -> PyResult {
208 let bytes = self.buffer.obj_bytes();
209 // TODO: Optimize
210 self.format_spec
211 .unpack(&bytes[pos..pos + self.desc.itemsize], vm)
212 .map(|x| {
213 if x.len() == 1 {
214 x[0].to_owned()
215 } else {
216 x.into()
217 }
218 })
219 }
220
221 fn pos_from_multi_index(&self, indexes: &[isize], vm: &VirtualMachine) -> PyResult<usize> {
222 match indexes.len().cmp(&self.desc.ndim()) {

Callers 2

getitem_by_idxMethod · 0.80
__getitem__Method · 0.80

Calls 5

obj_bytesMethod · 0.45
mapMethod · 0.45
unpackMethod · 0.45
lenMethod · 0.45
to_ownedMethod · 0.45

Tested by

no test coverage detected