Merged release21-maint changes.
[python/dscho.git] / Include / listobject.h
blobaf1368c987b298bec197b95ae353f3dd6ba2bd90
2 /* List object interface */
4 /*
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
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
22 typedef struct {
23 PyObject_VAR_HEAD
24 PyObject **ob_item;
25 } PyListObject;
27 extern DL_IMPORT(PyTypeObject) PyList_Type;
29 #define PyList_Check(op) PyObject_TypeCheck(op, &PyList_Type)
31 extern DL_IMPORT(PyObject *) PyList_New(int size);
32 extern DL_IMPORT(int) PyList_Size(PyObject *);
33 extern DL_IMPORT(PyObject *) PyList_GetItem(PyObject *, int);
34 extern DL_IMPORT(int) PyList_SetItem(PyObject *, int, PyObject *);
35 extern DL_IMPORT(int) PyList_Insert(PyObject *, int, PyObject *);
36 extern DL_IMPORT(int) PyList_Append(PyObject *, PyObject *);
37 extern DL_IMPORT(PyObject *) PyList_GetSlice(PyObject *, int, int);
38 extern DL_IMPORT(int) PyList_SetSlice(PyObject *, int, int, PyObject *);
39 extern DL_IMPORT(int) PyList_Sort(PyObject *);
40 extern DL_IMPORT(int) PyList_Reverse(PyObject *);
41 extern DL_IMPORT(PyObject *) PyList_AsTuple(PyObject *);
43 /* Macro, trading safety for speed */
44 #define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i])
45 #define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v))
46 #define PyList_GET_SIZE(op) (((PyListObject *)(op))->ob_size)
48 #ifdef __cplusplus
50 #endif
51 #endif /* !Py_LISTOBJECT_H */