Victor Stinner | 54ba556 | 2018-11-28 13:01:32 +0100 | [diff] [blame] | 1 | #ifndef Py_CPYTHON_TUPLEOBJECT_H |
| 2 | # error "this header file must not be included directly" |
| 3 | #endif |
| 4 | |
Victor Stinner | 54ba556 | 2018-11-28 13:01:32 +0100 | [diff] [blame] | 5 | typedef 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 | |
| 13 | PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, Py_ssize_t); |
| 14 | PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *); |
| 15 | |
| 16 | /* Macros trading safety for speed */ |
| 17 | |
| 18 | /* Cast argument to PyTupleObject* type. */ |
| 19 | #define _PyTuple_CAST(op) (assert(PyTuple_Check(op)), (PyTupleObject *)(op)) |
| 20 | |
| 21 | #define PyTuple_GET_SIZE(op) Py_SIZE(_PyTuple_CAST(op)) |
| 22 | |
| 23 | #define PyTuple_GET_ITEM(op, i) (_PyTuple_CAST(op)->ob_item[i]) |
| 24 | |
| 25 | /* Macro, *only* to be used to fill in brand new tuples */ |
| 26 | #define PyTuple_SET_ITEM(op, i, v) (_PyTuple_CAST(op)->ob_item[i] = v) |
| 27 | |
| 28 | PyAPI_FUNC(void) _PyTuple_DebugMallocStats(FILE *out); |