@@ -316,21 +316,24 @@ Py_SET_TYPE(PyObject *ob, PyTypeObject *type)
316316}
317317
318318#if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < _Py_PACK_VERSION (3 , 11 )
319- // Non-limited API & limited API 3.11 & below: the user can omit casts
319+ // Non-limited API & limited API 3.11 & below: use static inline functions and
320+ // use _PyObject_CAST so that users don't need their own casts
320321# define Py_TYPE (ob ) _Py_TYPE_impl(_PyObject_CAST(ob))
321322# define Py_SIZE (ob ) _Py_SIZE_impl(_PyObject_CAST(ob))
322323# define Py_IS_TYPE (ob , type ) _Py_IS_TYPE_impl(_PyObject_CAST(ob), (type))
323324# define Py_SET_SIZE (ob , size ) _Py_SET_SIZE_impl(_PyVarObject_CAST(ob), (size))
324325# define Py_SET_TYPE (ob , type ) Py_SET_TYPE(_PyObject_CAST(ob), type)
325326#elif Py_LIMITED_API + 0 < _Py_PACK_VERSION (3 , 15 )
326- # if Py_LIMITED_API + 0 < _Py_PACK_VERSION (3 , 14 )
327- // Py_TYPE() is a function call on Limited API 3.14 and newer
328- # define Py_TYPE (ob ) _Py_TYPE_impl(ob)
329- # endif
330- // These are function calls on Limited API 3.15 and newer:
327+ // Limited API 3.11-3.14: use static inline functions, without casts
331328# define Py_SIZE (ob ) _Py_SIZE_impl(ob)
332329# define Py_IS_TYPE (ob , type ) _Py_IS_TYPE_impl((ob), (type))
333330# define Py_SET_SIZE (ob , size ) _Py_SET_SIZE_impl((ob), (size))
331+ # if Py_LIMITED_API + 0 < _Py_PACK_VERSION (3 , 14 )
332+ // Py_TYPE() is static inline only on Limited API 3.13 and below
333+ # define Py_TYPE (ob ) _Py_TYPE_impl(ob)
334+ # endif
335+ #else
336+ // Limited API 3.15+: use function calls
334337#endif
335338
336339#endif // !defined(_Py_OPAQUE_PYOBJECT)
0 commit comments