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

Method __length_hint__

crates/vm/src/builtins/iter.rs:187–197  ·  view source on GitHub ↗
(&self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

185
186 #[pymethod]
187 fn __length_hint__(&self, vm: &VirtualMachine) -> PyObjectRef {
188 let internal = self.internal.lock();
189 if let IterStatus::Active(obj) = &internal.status {
190 let seq = obj.sequence_unchecked();
191 seq.length(vm)
192 .map(|x| PyInt::from(x).into_pyobject(vm))
193 .unwrap_or_else(|_| vm.ctx.not_implemented())
194 } else {
195 PyInt::from(0).into_pyobject(vm)
196 }
197 }
198
199 #[pymethod]
200 fn __reduce__(&self, vm: &VirtualMachine) -> PyTupleRef {

Callers

nothing calls this directly

Calls 6

sequence_uncheckedMethod · 0.80
lockMethod · 0.45
mapMethod · 0.45
lengthMethod · 0.45
into_pyobjectMethod · 0.45
not_implementedMethod · 0.45

Tested by

no test coverage detected