tupleobject.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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_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. PyAPI_FUNC(int) PyTuple_ClearFreeList(void);
  31. #ifndef Py_LIMITED_API
  32. # define Py_CPYTHON_TUPLEOBJECT_H
  33. # include "cpython/tupleobject.h"
  34. # undef Py_CPYTHON_TUPLEOBJECT_H
  35. #endif
  36. #ifdef __cplusplus
  37. }
  38. #endif
  39. #endif /* !Py_TUPLEOBJECT_H */