Message290078
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. |
|
Date |
User |
Action |
Args |
2017-03-24 05:26:32 | ncoghlan | set | recipients:
+ ncoghlan, vstinner, eric.snow, serhiy.storchaka |
2017-03-24 05:26:32 | ncoghlan | set | messageid: <1490333192.5.0.364110830576.issue29881@psf.upfronthosting.co.za> |
2017-03-24 05:26:32 | ncoghlan | link | issue29881 messages |
2017-03-24 05:26:31 | ncoghlan | create | |
|