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

Method __len__

crates/vm/src/builtins/memory.rs:699–708  ·  view source on GitHub ↗
(&self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

697 }
698
699 fn __len__(&self, vm: &VirtualMachine) -> PyResult<usize> {
700 self.try_not_released(vm)?;
701 if self.desc.ndim() == 0 {
702 // 0-dimensional memoryview has no length
703 Err(vm.new_type_error("0-dim memory has no length"))
704 } else {
705 // shape for dim[0]
706 Ok(self.desc.dim_desc[0].0)
707 }
708 }
709
710 #[pymethod]
711 fn tobytes(&self, vm: &VirtualMachine) -> PyResult<PyBytesRef> {

Callers 1

nextMethod · 0.45

Calls 3

try_not_releasedMethod · 0.80
ErrClass · 0.50
ndimMethod · 0.45

Tested by

no test coverage detected