➜

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.

作者 vstinner
收信人 eric.snow, ncoghlan, serhiy.storchaka, vstinner
日期 2017-03-23.13:07:10
SpamBayes Score -1.0
Marked as misclassified 是
Message-id <1490274431.05.0.200398725258.issue29881@psf.upfronthosting.co.za>
In-reply-to
内容
> * do we ever declare non-statics this way? (OTOH, if we do, this could be an opportunity to hide them behind read-only accessor functions)
> * do we ever declare more specific types than PyObject * this way? (OTOH, if that's the uncommon case, requiring a cast to the more specific type probably wouldn't hurt)

Well, with my 2nd API, I'm not sure that the macro to declare a variable is very simple:

+/* Declare a static PyObject* variable which is only initialized once.
+   _PyOnceVar_Fini() will clear the variable at Python finalization. */
+#define _Py_ONCEVAR(var) \
+    static PyObject* var = NULL

Technically, the variable doesn't have to be static. But do we want to use this API for global variables initialized once? It would increase the memory usage, whereas currently we have specialized code like _PyUnicode_Fini() which clears its unicode_empty singleton. I don't want to touch this code. At least, not yet.

If you want to support other types than PyObject*, _PY_ONCEVAR_INIT() macro can cast the first argument to PyObject*.

I would prefer to start with something simpler, and discuss case by case for other variables.
历史
日期 用户 动作 参数
2017-03-23 13:07:11vstinner修改recipients: + vstinner, ncoghlan, eric.snow, serhiy.storchaka
2017-03-23 13:07:11vstinner修改messageid: <1490274431.05.0.200398725258.issue29881@psf.upfronthosting.co.za>
2017-03-23 13:07:11vstinner链接issue29881 messages
2017-03-23 13:07:10vstinner创建