• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Tuple object interface */
2 
3 #ifndef Py_TUPLEOBJECT_H
4 #define Py_TUPLEOBJECT_H
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8 
9 /*
10 Another generally useful object type is a tuple of object pointers.
11 For 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
13 object references, but in general only brand new tuples should be mutated,
14 not ones that might already have been exposed to Python code.
15 
16 *** WARNING *** PyTuple_SetItem does not increment the new item's reference
17 count, but does decrement the reference count of the item it replaces,
18 if not nil.  It does *decrement* the reference count if it is *not*
19 inserted in the tuple.  Similarly, PyTuple_GetItem does not increment the
20 returned item's reference count.
21 */
22 
23 PyAPI_DATA(PyTypeObject) PyTuple_Type;
24 PyAPI_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 
30 PyAPI_FUNC(PyObject *) PyTuple_New(Py_ssize_t size);
31 PyAPI_FUNC(Py_ssize_t) PyTuple_Size(PyObject *);
32 PyAPI_FUNC(PyObject *) PyTuple_GetItem(PyObject *, Py_ssize_t);
33 PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *);
34 PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t);
35 PyAPI_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