Message290040
| Author |
vstinner |
| Recipients |
eric.snow, ncoghlan, serhiy.storchaka, vstinner |
| Date |
2017年03月23日.10:54:42 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1490266482.75.0.76285351757.issue29881@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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*. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2017年03月23日 10:54:42 | vstinner | set | recipients:
+ vstinner, ncoghlan, eric.snow, serhiy.storchaka |
| 2017年03月23日 10:54:42 | vstinner | set | messageid: <1490266482.75.0.76285351757.issue29881@psf.upfronthosting.co.za> |
| 2017年03月23日 10:54:42 | vstinner | link | issue29881 messages |
| 2017年03月23日 10:54:42 | vstinner | create |
|