Author vstinner
Recipients vstinner
Date 2020-05-11.22:49:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> 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...
Date User Action Args
2020-05-11 22:49:41vstinnersetrecipients: + vstinner
2020-05-11 22:49:41vstinnersetmessageid: <>
2020-05-11 22:49:41vstinnerlinkissue40601 messages
2020-05-11 22:49:41vstinnercreate