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

Function range_iter_reduce

crates/vm/src/builtins/range.rs:714–729  ·  view source on GitHub ↗
(
    start: BigInt,
    length: BigInt,
    step: BigInt,
    index: usize,
    vm: &VirtualMachine,
)

Source from the content-addressed store, hash-verified

712}
713
714fn range_iter_reduce(
715 start: BigInt,
716 length: BigInt,
717 step: BigInt,
718 index: usize,
719 vm: &VirtualMachine,
720) -> PyResult<PyTupleRef> {
721 let iter = builtins_iter(vm);
722 let stop = start.clone() + length * step.clone();
723 let range = PyRange {
724 start: PyInt::from(start).into_ref(&vm.ctx),
725 stop: PyInt::from(stop).into_ref(&vm.ctx),
726 step: PyInt::from(step).into_ref(&vm.ctx),
727 };
728 Ok(vm.new_tuple((iter, (range,), index)))
729}
730
731// Silently clips state (i.e index) in range [0, usize::MAX].
732fn range_state(length: &BigInt, state: PyObjectRef, vm: &VirtualMachine) -> PyResult<usize> {

Callers 1

__reduce__Method · 0.85

Calls 4

builtins_iterFunction · 0.85
cloneMethod · 0.45
into_refMethod · 0.45
new_tupleMethod · 0.45

Tested by

no test coverage detected