消息 [368676]
> I propose to break the limited C API backward compatibility on purpose by removing these type definitions form the limited C API.
Hum. How would a C extension subclass the Python int type (PyLong_Type) if it's no longer exposed? One option is to add one function per type, like:
PyObject* Py_GetLongType(void);
It would return a *strong reference* to the type (PyLong_Type).
Another option is to get the type from builtins module or builtins dictionary (PyInterpreterState.builtins). But there is no simple C function to get a builtin object. It requires many calls, handle errors, etc. Maybe a generic helper like the following function would help:
PyObject *Py_GetBuiltin(const char *name);
Note: PyEval_GetBuiltins() exposes the builtins of the *current frame* which maybe not be what you may expect.
Currently, Py_GetBuiltin(name) is not needed since basically *all* Python builtins are *directly* exposed in the C API... |
|
| 日期 |
用户 |
动作 |
参数 |
| 2020-05-11 22:49:41 | vstinner | 修改 | recipients:
+ vstinner |
| 2020-05-11 22:49:41 | vstinner | 修改 | messageid: <1589237381.24.0.351486868904.issue40601@roundup.psfhosted.org> |
| 2020-05-11 22:49:41 | vstinner | 链接 | issue40601 messages |
| 2020-05-11 22:49:41 | vstinner | 创建 | |
|