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

Function get_items_iter

crates/vm/src/builtins/object.rs:672–687  ·  view source on GitHub ↗

Get list items iterator if obj is a list (or subclass), None iterator otherwise

(obj: &PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

670
671/// Get list items iterator if obj is a list (or subclass), None iterator otherwise
672fn get_items_iter(obj: &PyObjectRef, vm: &VirtualMachine) -> PyResult<(PyObjectRef, PyObjectRef)> {
673 let listitems: PyObjectRef = if obj.fast_isinstance(vm.ctx.types.list_type) {
674 obj.get_iter(vm)?.into()
675 } else {
676 vm.ctx.none()
677 };
678
679 let dictitems: PyObjectRef = if obj.fast_isinstance(vm.ctx.types.dict_type) {
680 let items = vm.call_method(obj, "items", ())?;
681 items.get_iter(vm)?.into()
682 } else {
683 vm.ctx.none()
684 };
685
686 Ok((listitems, dictitems))
687}
688
689/// reduce_newobj - creates reduce tuple for protocol >= 2
690fn reduce_newobj(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult {

Callers 1

reduce_newobjFunction · 0.85

Calls 4

fast_isinstanceMethod · 0.80
get_iterMethod · 0.80
noneMethod · 0.80
call_methodMethod · 0.45

Tested by

no test coverage detected