Message361122
| 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. |
|