Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-19 09:50:43

0001 #ifndef Py_CPYTHON_TUPLEOBJECT_H
0002 #  error "this header file must not be included directly"
0003 #endif
0004 
0005 typedef struct {
0006     PyObject_VAR_HEAD
0007     /* ob_item contains space for 'ob_size' elements.
0008        Items must normally not be NULL, except during construction when
0009        the tuple is not yet visible outside the function that builds it. */
0010     PyObject *ob_item[1];
0011 } PyTupleObject;
0012 
0013 PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, Py_ssize_t);
0014 
0015 /* Cast argument to PyTupleObject* type. */
0016 #define _PyTuple_CAST(op) \
0017     (assert(PyTuple_Check(op)), _Py_CAST(PyTupleObject*, (op)))
0018 
0019 // Macros and static inline functions, trading safety for speed
0020 
0021 static inline Py_ssize_t PyTuple_GET_SIZE(PyObject *op) {
0022     PyTupleObject *tuple = _PyTuple_CAST(op);
0023     return Py_SIZE(tuple);
0024 }
0025 #define PyTuple_GET_SIZE(op) PyTuple_GET_SIZE(_PyObject_CAST(op))
0026 
0027 #define PyTuple_GET_ITEM(op, index) (_PyTuple_CAST(op)->ob_item[(index)])
0028 
0029 /* Function *only* to be used to fill in brand new tuples */
0030 static inline void
0031 PyTuple_SET_ITEM(PyObject *op, Py_ssize_t index, PyObject *value) {
0032     PyTupleObject *tuple = _PyTuple_CAST(op);
0033     assert(0 <= index);
0034     assert(index < Py_SIZE(tuple));
0035     tuple->ob_item[index] = value;
0036 }
0037 #define PyTuple_SET_ITEM(op, index, value) \
0038     PyTuple_SET_ITEM(_PyObject_CAST(op), (index), _PyObject_CAST(value))