Hi Antoine,
*Getting* an object type and an object size using Py_TYPE() and Py_SIZE() remains valid and is still supported. There is no problem with that.
Python 3.11 breaks the few C extensions which use Py_TYPE() and Py_SIZE() to *set* an object type or an object size: Py_SET_TYPE() and Py_SET_SIZE() must be used.
Py_SET_SIZE() and Py_SET_TYPE() exists for 2 Python releases (added to Python 3.9). Py_TYPE() requires to call Py_SET_TYPE() to set an object in Python 3.10 documentation (same for Py_SIZE): https://docs.python.org/3.10/c-api/structures.html#c.Py_TYPE
--
Deprecating Py_TYPE/Py_SIZE would affect way more C extensions, no? Requiring C extensions to replace Py_TYPE() with Py_GetTypeInline() and replacing Py_SIZE() with Py_GetSizeInline() would require more work and has no benefit, no? I'm not sure that I get your point. Is it about keeping Py_TYPE/Py_SIZE for a few more Python releases?
Victor
On Mon, Sep 13, 2021 at 5:23 PM Antoine Pitrou <antoine@python.org> wrote:
One solution would be to:
introduce Py_GetSizeInline(), Py_GetTypeInline() static inline functions (of course, feel free to prefer other names :-))
deprecate Py_SIZE() and Py_TYPE() with a message guiding towards Py_GetSizeInline() and Py_GetTypeInline() respectively. To be clear, this is a compile-time deprecation message using pragmas or other compiler-specific means (see e.g. https://stackoverflow.com/questions/2681259/how-to-deprecate-a-c-pre-process...).
in a couple versions, retire the current definitions of Py_SIZE and Py_TYPE and replace them with:
#define Py_SIZE Py_GetSizeInline #define Py_TYPE Py_GetTypeInline
Regards
Antoine.
Le 13/09/2021 à 16:52, Antonio Cuni a écrit :
On Mon, Sep 13, 2021 at 11:37 AM Petr Viktorin <encukou@gmail.com> wrote:
Sure, let's evolve and improve CPython. But can we make it in steps that are individually helpful?
I think that's the core of the divergences of opinions. I think we have reached a point where the amount of improvements which can be done by "small steps which are individually useful" is little. I might be wrong of course.
capi-sig mailing list -- capi-sig@python.org To unsubscribe send an email to capi-sig-leave@python.org https://mail.python.org/mailman3/lists/capi-sig.python.org/ Member address: antoine@python.org
capi-sig mailing list -- capi-sig@python.org To unsubscribe send an email to capi-sig-leave@python.org https://mail.python.org/mailman3/lists/capi-sig.python.org/ Member address: vstinner@python.org
-- Night gathers, and now my watch begins. It shall not end until my death.