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

Method get_weak_references

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

Source from the content-addressed store, hash-verified

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);
765 let mut v = Vec::new();
766 let mut current = NonNull::new(self.head.load(Ordering::Relaxed));
767 while let Some(node) = current {
768 let wr = unsafe { node.as_ref() };
769 if wr.0.ref_count.safe_inc() {
770 v.push(unsafe { PyRef::from_raw(wr as *const Py<PyWeak>) });
771 }
772 current = unsafe { WeakLink::pointers(node).as_ref().get_next() };
773 }
774 v
775 }
776}
777
778impl Default for WeakRefList {

Callers 1

getweakrefsFunction · 0.80

Calls 9

lockFunction · 0.85
newFunction · 0.85
safe_incMethod · 0.80
get_nextMethod · 0.80
weak_ref_listMethod · 0.80
loadMethod · 0.45
as_refMethod · 0.45
pushMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected