1#ifndef Py_CPYTHON_TUPLEOBJECT_H 2# error "this header file must not be included directly" 3#endif 4 5typedef struct { 6 PyObject_VAR_HEAD 7 /* ob_item contains space for 'ob_size' elements. 8 Items must normally not be NULL, except during construction when 9 the tuple is not yet visible outside the function that builds it. */ 10 PyObject *ob_item[1]; 11} PyTupleObject; 12 13PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, Py_ssize_t); 14PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *); 15 16/* Cast argument to PyTupleObject* type. */ 17#define _PyTuple_CAST(op) \ 18 (assert(PyTuple_Check(op)), _Py_CAST(PyTupleObject*, (op))) 19 20// Macros and static inline functions, trading safety for speed 21 22static inline Py_ssize_t PyTuple_GET_SIZE(PyObject *op) { 23 PyTupleObject *tuple = _PyTuple_CAST(op); 24 return Py_SIZE(tuple); 25} 26#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 27# define PyTuple_GET_SIZE(op) PyTuple_GET_SIZE(_PyObject_CAST(op)) 28#endif 29 30#define PyTuple_GET_ITEM(op, index) (_PyTuple_CAST(op)->ob_item[index]) 31 32/* Function *only* to be used to fill in brand new tuples */ 33static inline void 34PyTuple_SET_ITEM(PyObject *op, Py_ssize_t index, PyObject *value) { 35 PyTupleObject *tuple = _PyTuple_CAST(op); 36 tuple->ob_item[index] = value; 37} 38#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 39#define PyTuple_SET_ITEM(op, index, value) \ 40 PyTuple_SET_ITEM(_PyObject_CAST(op), index, _PyObject_CAST(value)) 41#endif 42 43PyAPI_FUNC(void) _PyTuple_DebugMallocStats(FILE *out); 44