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

Method _getitem

crates/vm/src/builtins/bytearray.rs:129–140  ·  view source on GitHub ↗
(&self, needle: &PyObject, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

127 }
128
129 fn _getitem(&self, needle: &PyObject, vm: &VirtualMachine) -> PyResult {
130 match SequenceIndex::try_from_borrowed_object(vm, needle, "bytearray")? {
131 SequenceIndex::Int(i) => self
132 .borrow_buf()
133 .getitem_by_index(vm, i)
134 .map(|x| vm.ctx.new_int(x).into()),
135 SequenceIndex::Slice(slice) => self
136 .borrow_buf()
137 .getitem_by_slice(vm, slice)
138 .map(|x| vm.ctx.new_bytearray(x).into()),
139 }
140 }
141
142 pub fn _delitem(&self, needle: &PyObject, vm: &VirtualMachine) -> PyResult<()> {
143 match SequenceIndex::try_from_borrowed_object(vm, needle, "bytearray")? {

Callers 1

__getitem__Method · 0.45

Calls 6

new_bytearrayMethod · 0.80
mapMethod · 0.45
getitem_by_indexMethod · 0.45
borrow_bufMethod · 0.45
new_intMethod · 0.45
getitem_by_sliceMethod · 0.45

Tested by

no test coverage detected