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

Method del_item

crates/vm/src/protocol/object.rs:771–788  ·  view source on GitHub ↗
(&self, needle: &K, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

769 }
770
771 pub fn del_item<K: DictKey + ?Sized>(&self, needle: &K, vm: &VirtualMachine) -> PyResult<()> {
772 if let Some(dict) = self.downcast_ref_if_exact::<PyDict>(vm) {
773 return dict.del_item(needle, vm);
774 }
775
776 let mapping = self.mapping_unchecked();
777 if let Some(f) = mapping.slots().ass_subscript.load() {
778 let needle = needle.to_pyobject(vm);
779 return f(mapping, &needle, None, vm);
780 }
781 let seq = self.sequence_unchecked();
782 if let Some(f) = seq.slots().ass_item.load() {
783 let i = needle.key_as_isize(vm)?;
784 return f(seq, i, None, vm);
785 }
786
787 Err(vm.new_type_error(format!("'{}' does not support item deletion", self.class())))
788 }
789
790 /// Equivalent to CPython's _PyObject_LookupSpecial
791 /// Looks up a special method in the type's MRO without checking instance dict.

Callers 1

generic_setattrMethod · 0.45

Calls 8

mapping_uncheckedMethod · 0.80
sequence_uncheckedMethod · 0.80
key_as_isizeMethod · 0.80
fFunction · 0.50
ErrClass · 0.50
loadMethod · 0.45
slotsMethod · 0.45
to_pyobjectMethod · 0.45

Tested by

no test coverage detected