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.

Author vstinner
Recipients vstinner
Date 2020-05-11.22:49:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1589237381.24.0.351486868904.issue40601@roundup.psfhosted.org>
In-reply-to
Content
> 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...
History
Date User Action Args
2020-05-11 22:49:41vstinnersetrecipients: + vstinner
2020-05-11 22:49:41vstinnersetmessageid: <1589237381.24.0.351486868904.issue40601@roundup.psfhosted.org>
2020-05-11 22:49:41vstinnerlinkissue40601 messages
2020-05-11 22:49:41vstinnercreate