Message361122
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. |
|
Date |
User |
Action |
Args |
2020-01-31 17:11:18 | jkloth | set | recipients:
+ jkloth, ncoghlan, vstinner, eric.snow, nanjekyejoannah |
2020-01-31 17:11:18 | jkloth | set | messageid: <1580490678.16.0.883344309712.issue39511@roundup.psfhosted.org> |
2020-01-31 17:11:18 | jkloth | link | issue39511 messages |
2020-01-31 17:11:18 | jkloth | create | |
|