Jeremy Kloth <[email protected]> added the comment:
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.
----------
nosy: +jkloth
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue39511>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com