1/* Tuple object interface */
2
3#ifndef Py_TUPLEOBJECT_H
4#define Py_TUPLEOBJECT_H
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9/*
10Another generally useful object type is a tuple of object pointers.
11For Python, this is an immutable type. C code can change the tuple items
12(but not their number), and even use tuples as general-purpose arrays of
13object references, but in general only brand new tuples should be mutated,
14not ones that might already have been exposed to Python code.
15
16*** WARNING *** PyTuple_SetItem does not increment the new item's reference
17count, but does decrement the reference count of the item it replaces,
18if not nil. It does *decrement* the reference count if it is *not*
19inserted in the tuple. Similarly, PyTuple_GetItem does not increment the
20returned item's reference count.
21*/
22
23PyAPI_DATA(PyTypeObject) PyTuple_Type;
24PyAPI_DATA(PyTypeObject) PyTupleIter_Type;
25
26#define PyTuple_Check(op) \
27 PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TUPLE_SUBCLASS)
28#define PyTuple_CheckExact(op) Py_IS_TYPE(op, &PyTuple_Type)
29
30PyAPI_FUNC(PyObject *) PyTuple_New(Py_ssize_t size);
31PyAPI_FUNC(Py_ssize_t) PyTuple_Size(PyObject *);
32PyAPI_FUNC(PyObject *) PyTuple_GetItem(PyObject *, Py_ssize_t);
33PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *);
34PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t);
35PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...);
36
37#ifndef Py_LIMITED_API
38# define Py_CPYTHON_TUPLEOBJECT_H
39# include "cpython/tupleobject.h"
40# undef Py_CPYTHON_TUPLEOBJECT_H
41#endif
42
43#ifdef __cplusplus
44}
45#endif
46#endif /* !Py_TUPLEOBJECT_H */
47

source code of include/python3.10/tupleobject.h