2 /* List object interface */
5 Another generally useful object type is an list of object pointers.
6 This is a mutable type: the list items can be changed, and items can be
7 added or removed. Out-of-range indices or non-list objects are ignored.
9 *** WARNING *** PyList_SetItem does not increment the new item's reference
10 count, but does decrement the reference count of the item it replaces,
11 if not nil. It does *decrement* the reference count if it is *not*
12 inserted in the list. Similarly, PyList_GetItem does not increment the
13 returned item's reference count.
16 #ifndef Py_LISTOBJECT_H
17 #define Py_LISTOBJECT_H
27 extern DL_IMPORT(PyTypeObject
) PyList_Type
;
29 #define PyList_Check(op) PyObject_TypeCheck(op, &PyList_Type)
30 #define PyList_CheckExact(op) ((op)->ob_type == &PyList_Type)
32 extern DL_IMPORT(PyObject
*) PyList_New(int size
);
33 extern DL_IMPORT(int) PyList_Size(PyObject
*);
34 extern DL_IMPORT(PyObject
*) PyList_GetItem(PyObject
*, int);
35 extern DL_IMPORT(int) PyList_SetItem(PyObject
*, int, PyObject
*);
36 extern DL_IMPORT(int) PyList_Insert(PyObject
*, int, PyObject
*);
37 extern DL_IMPORT(int) PyList_Append(PyObject
*, PyObject
*);
38 extern DL_IMPORT(PyObject
*) PyList_GetSlice(PyObject
*, int, int);
39 extern DL_IMPORT(int) PyList_SetSlice(PyObject
*, int, int, PyObject
*);
40 extern DL_IMPORT(int) PyList_Sort(PyObject
*);
41 extern DL_IMPORT(int) PyList_Reverse(PyObject
*);
42 extern DL_IMPORT(PyObject
*) PyList_AsTuple(PyObject
*);
44 /* Macro, trading safety for speed */
45 #define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i])
46 #define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v))
47 #define PyList_GET_SIZE(op) (((PyListObject *)(op))->ob_size)
52 #endif /* !Py_LISTOBJECT_H */