消息 [290040]
I wrote a new different API: https://github.com/python/cpython/pull/780
New C API for variables only initialized once to be able to clear
them at exit:
New macro _Py_ONCEVAR(var) to declare a variable
New macro _PY_ONCEVAR_INIT(var, expr) to initialize a variable
once
New function _PyOnceVar_Set() to explicitly set a variable once
to initialize it
New _PyOnceVar_Fini() function clearing all variables (initialized
once) at exit
Variables keep their PyObject* type, but the API hides an internal C array tracking all Python objects to Py_DECREF them at exit in _PyOnceVar_Fini().
I used Nick's naming scheme since it seems like pthread has an existing API which is similar, but different (my API doesn't require an initialization callback).
I really prefer the second API using PyObject*. |
|
| 日期 |
用户 |
动作 |
参数 |
| 2017-03-23 10:54:42 | vstinner | 修改 | recipients:
+ vstinner, ncoghlan, eric.snow, serhiy.storchaka |
| 2017-03-23 10:54:42 | vstinner | 修改 | messageid: <1490266482.75.0.76285351757.issue29881@psf.upfronthosting.co.za> |
| 2017-03-23 10:54:42 | vstinner | 链接 | issue29881 messages |
| 2017-03-23 10:54:42 | vstinner | 创建 | |
|