MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / len

Method len

src/objectprotocol.rs:280–287  ·  view source on GitHub ↗
(&self, py: Python)

Source from the content-addressed store, hash-verified

278 /// This is equivalent to the Python expression: 'len(self)'
279 #[inline]
280 fn len(&self, py: Python) -> PyResult<usize> {
281 let v = unsafe { ffi::PyObject_Size(self.as_ptr()) };
282 if v == -1 {
283 Err(PyErr::fetch(py))
284 } else {
285 Ok(v as usize)
286 }
287 }
288
289 /// This is equivalent to the Python expression: 'self[key]'
290 #[inline]

Callers

nothing calls this directly

Implementers 1

objectprotocol.rssrc/objectprotocol.rs

Calls 1

as_ptrMethod · 0.45

Tested by

no test coverage detected