blob: 51dcd4237be18ce2542ae72784c7e9980d1e6bfa [file] [log] [blame]
Victor Stinner54ba5562018-11-28 13:01:32 +01001#ifndef Py_CPYTHON_TUPLEOBJECT_H
2# error "this header file must not be included directly"
3#endif
4
Victor Stinner54ba5562018-11-28 13:01:32 +01005typedef 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/* 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
28PyAPI_FUNC(void) _PyTuple_DebugMallocStats(FILE *out);