1 /* List object interface 2 3 Another generally useful object type is a list of object pointers. 4 This is a mutable type: the list items can be changed, and items can be 5 added or removed. Out-of-range indices or non-list objects are ignored. 6 7 WARNING: PyList_SetItem does not increment the new item's reference count, 8 but does decrement the reference count of the item it replaces, if not nil. 9 It does *decrement* the reference count if it is *not* inserted in the list. 10 Similarly, PyList_GetItem does not increment the returned item's reference 11 count. 12 */ 13 14 #ifndef Py_LISTOBJECT_H 15 #define Py_LISTOBJECT_H 16 #ifdef __cplusplus 17 extern "C" { 18 #endif 19 20 PyAPI_DATA(PyTypeObject) PyList_Type; 21 PyAPI_DATA(PyTypeObject) PyListIter_Type; 22 PyAPI_DATA(PyTypeObject) PyListRevIter_Type; 23 24 #define PyList_Check(op) \ 25 PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS) 26 #define PyList_CheckExact(op) Py_IS_TYPE((op), &PyList_Type) 27 28 PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size); 29 PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *); 30 31 PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, Py_ssize_t); 32 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000 33 PyAPI_FUNC(PyObject *) PyList_GetItemRef(PyObject *, Py_ssize_t); 34 #endif 35 PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *); 36 PyAPI_FUNC(int) PyList_Insert(PyObject *, Py_ssize_t, PyObject *); 37 PyAPI_FUNC(int) PyList_Append(PyObject *, PyObject *); 38 39 PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t); 40 PyAPI_FUNC(int) PyList_SetSlice(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *); 41 42 PyAPI_FUNC(int) PyList_Sort(PyObject *); 43 PyAPI_FUNC(int) PyList_Reverse(PyObject *); 44 PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *); 45 46 #ifndef Py_LIMITED_API 47 # define Py_CPYTHON_LISTOBJECT_H 48 # include "cpython/listobject.h" 49 # undef Py_CPYTHON_LISTOBJECT_H 50 #endif 51 52 #ifdef __cplusplus 53 } 54 #endif 55 #endif /* !Py_LISTOBJECT_H */ 56