annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/python3.8/listobject.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1
jpayne@69 2 /* List object interface */
jpayne@69 3
jpayne@69 4 /*
jpayne@69 5 Another generally useful object type is a list of object pointers.
jpayne@69 6 This is a mutable type: the list items can be changed, and items can be
jpayne@69 7 added or removed. Out-of-range indices or non-list objects are ignored.
jpayne@69 8
jpayne@69 9 *** WARNING *** PyList_SetItem does not increment the new item's reference
jpayne@69 10 count, but does decrement the reference count of the item it replaces,
jpayne@69 11 if not nil. It does *decrement* the reference count if it is *not*
jpayne@69 12 inserted in the list. Similarly, PyList_GetItem does not increment the
jpayne@69 13 returned item's reference count.
jpayne@69 14 */
jpayne@69 15
jpayne@69 16 #ifndef Py_LISTOBJECT_H
jpayne@69 17 #define Py_LISTOBJECT_H
jpayne@69 18 #ifdef __cplusplus
jpayne@69 19 extern "C" {
jpayne@69 20 #endif
jpayne@69 21
jpayne@69 22 #ifndef Py_LIMITED_API
jpayne@69 23 typedef struct {
jpayne@69 24 PyObject_VAR_HEAD
jpayne@69 25 /* Vector of pointers to list elements. list[0] is ob_item[0], etc. */
jpayne@69 26 PyObject **ob_item;
jpayne@69 27
jpayne@69 28 /* ob_item contains space for 'allocated' elements. The number
jpayne@69 29 * currently in use is ob_size.
jpayne@69 30 * Invariants:
jpayne@69 31 * 0 <= ob_size <= allocated
jpayne@69 32 * len(list) == ob_size
jpayne@69 33 * ob_item == NULL implies ob_size == allocated == 0
jpayne@69 34 * list.sort() temporarily sets allocated to -1 to detect mutations.
jpayne@69 35 *
jpayne@69 36 * Items must normally not be NULL, except during construction when
jpayne@69 37 * the list is not yet visible outside the function that builds it.
jpayne@69 38 */
jpayne@69 39 Py_ssize_t allocated;
jpayne@69 40 } PyListObject;
jpayne@69 41 #endif
jpayne@69 42
jpayne@69 43 PyAPI_DATA(PyTypeObject) PyList_Type;
jpayne@69 44 PyAPI_DATA(PyTypeObject) PyListIter_Type;
jpayne@69 45 PyAPI_DATA(PyTypeObject) PyListRevIter_Type;
jpayne@69 46 PyAPI_DATA(PyTypeObject) PySortWrapper_Type;
jpayne@69 47
jpayne@69 48 #define PyList_Check(op) \
jpayne@69 49 PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS)
jpayne@69 50 #define PyList_CheckExact(op) (Py_TYPE(op) == &PyList_Type)
jpayne@69 51
jpayne@69 52 PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size);
jpayne@69 53 PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *);
jpayne@69 54 PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, Py_ssize_t);
jpayne@69 55 PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *);
jpayne@69 56 PyAPI_FUNC(int) PyList_Insert(PyObject *, Py_ssize_t, PyObject *);
jpayne@69 57 PyAPI_FUNC(int) PyList_Append(PyObject *, PyObject *);
jpayne@69 58 PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t);
jpayne@69 59 PyAPI_FUNC(int) PyList_SetSlice(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *);
jpayne@69 60 PyAPI_FUNC(int) PyList_Sort(PyObject *);
jpayne@69 61 PyAPI_FUNC(int) PyList_Reverse(PyObject *);
jpayne@69 62 PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *);
jpayne@69 63 #ifndef Py_LIMITED_API
jpayne@69 64 PyAPI_FUNC(PyObject *) _PyList_Extend(PyListObject *, PyObject *);
jpayne@69 65
jpayne@69 66 PyAPI_FUNC(int) PyList_ClearFreeList(void);
jpayne@69 67 PyAPI_FUNC(void) _PyList_DebugMallocStats(FILE *out);
jpayne@69 68 #endif
jpayne@69 69
jpayne@69 70 /* Macro, trading safety for speed */
jpayne@69 71 #ifndef Py_LIMITED_API
jpayne@69 72 #define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i])
jpayne@69 73 #define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v))
jpayne@69 74 #define PyList_GET_SIZE(op) (assert(PyList_Check(op)),Py_SIZE(op))
jpayne@69 75 #define _PyList_ITEMS(op) (((PyListObject *)(op))->ob_item)
jpayne@69 76 #endif
jpayne@69 77
jpayne@69 78 #ifdef __cplusplus
jpayne@69 79 }
jpayne@69 80 #endif
jpayne@69 81 #endif /* !Py_LISTOBJECT_H */