This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients eric.snow, ncoghlan, serhiy.storchaka, vstinner
Date 2017-03-24.05:26:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1490333192.5.0.364110830576.issue29881@psf.upfronthosting.co.za>
In-reply-to
Content
The main potential benefit I see to keeping the special variable declaration is that it may help avoid a certain category of error: calling _Py_ONCE_VAR_INIT on a stack local pointer reference (which would leave the global array with a reference to nonsense). While we don't care if the once_vars are static or not, we do care that they're not allocated on the call stack, as otherwise they won't be around for Py_Finalize() to clean up.

On the other hand, _Py_SET_ONCE is nice and easy to explain "it's similar to _Py_SETREF, but: 1) doesn't do anything if the reference is already set; and 2) registers the reference to be cleaned up in Py_Finalize"

Also interesting is the fact that you can still use _Py_SETREF to change a reference that was initialized with _Py_SET_ONCE without breaking anything. From that point of view, a better name might be _Py_SET_FINALIZED, emphasising the fact that it registers the pointer for finalization over the fact that it's a no-op when run on an already set pointer.
History
Date User Action Args
2017-03-24 05:26:32ncoghlansetrecipients: + ncoghlan, vstinner, eric.snow, serhiy.storchaka
2017-03-24 05:26:32ncoghlansetmessageid: <1490333192.5.0.364110830576.issue29881@psf.upfronthosting.co.za>
2017-03-24 05:26:32ncoghlanlinkissue29881 messages
2017-03-24 05:26:31ncoghlancreate