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

Method count

crates/vm/src/object/core.rs:750–761  ·  view source on GitHub ↗
(&self, obj: &PyObject)

Source from the content-addressed store, hash-verified

748 }
749
750 fn count(&self, obj: &PyObject) -> usize {
751 let _lock = weakref_lock::lock(obj as *const PyObject as usize);
752 let mut count = 0usize;
753 let mut current = NonNull::new(self.head.load(Ordering::Relaxed));
754 while let Some(node) = current {
755 if unsafe { node.as_ref() }.0.ref_count.get() > 0 {
756 count += 1;
757 }
758 current = unsafe { WeakLink::pointers(node).as_ref().get_next() };
759 }
760 count
761 }
762
763 fn get_weak_references(&self, obj: &PyObject) -> Vec<PyRef<PyWeak>> {
764 let _lock = weakref_lock::lock(obj as *const PyObject as usize);

Callers 2

traverseMethod · 0.45
weak_countMethod · 0.45

Calls 6

lockFunction · 0.85
newFunction · 0.85
get_nextMethod · 0.80
loadMethod · 0.45
getMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected