tupleobject.h 1.6 KB

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