Author jkloth
Recipients eric.snow, jkloth, nanjekyejoannah, ncoghlan, vstinner
Date 2020-01-31.17:11:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1580490678.16.0.883344309712.issue39511@roundup.psfhosted.org>
In-reply-to
Content
Would it not suffice to just make the singletons "immortal"?

Without affecting the hotpaths that are Py_INCREF and Py_DECREF, changing _Py_Dealloc to test for objects with a "special" destructor could be used:

    destructor dealloc = Py_TYPE(op)->tp_dealloc;
    if (dealloc == _Py_SingletonSentinel) {
        /* reset refcnt so as to not return here too often */
        op->ob_refcnt = PY_SSIZE_T_MAX;
    }
    else {
        (*dealloc)(op);
    }

Even in the presence of multiple mutating threads, the object cannot be destroyed.  Worst case, they all call _Py_Dealloc.
History
Date User Action Args
2020-01-31 17:11:18jklothsetrecipients: + jkloth, ncoghlan, vstinner, eric.snow, nanjekyejoannah
2020-01-31 17:11:18jklothsetmessageid: <1580490678.16.0.883344309712.issue39511@roundup.psfhosted.org>
2020-01-31 17:11:18jklothlinkissue39511 messages
2020-01-31 17:11:18jklothcreate