public static void SetFinalizerHelper(IPythonObject obj, WeakRefTracker value) { object[] slots = obj.GetSlotsCreate(); if (Interlocked.CompareExchange(ref slots[slots.Length - 1], value, null) != null) { GC.SuppressFinalize(value); } }
public static bool SetWeakRefHelper(IPythonObject obj, WeakRefTracker value) { if (!obj.PythonType.IsWeakReferencable) { return(false); } object[] slots = obj.GetSlotsCreate(); slots[slots.Length - 1] = value; return(true); }