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

Method _getitem

crates/vm/src/builtins/bytes.rs:162–171  ·  view source on GitHub ↗
(&self, needle: &PyObject, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

160 }
161
162 fn _getitem(&self, needle: &PyObject, vm: &VirtualMachine) -> PyResult {
163 match SequenceIndex::try_from_borrowed_object(vm, needle, "byte")? {
164 SequenceIndex::Int(i) => self
165 .getitem_by_index(vm, i)
166 .map(|x| vm.ctx.new_int(x).into()),
167 SequenceIndex::Slice(slice) => self
168 .getitem_by_slice(vm, slice)
169 .map(|x| vm.ctx.new_bytes(x).into()),
170 }
171 }
172}
173
174impl PyRef<PyBytes> {

Callers 1

__getitem__Method · 0.45

Calls 5

mapMethod · 0.45
getitem_by_indexMethod · 0.45
new_intMethod · 0.45
getitem_by_sliceMethod · 0.45
new_bytesMethod · 0.45

Tested by

no test coverage detected