1 #ifndef Py_CPYTHON_LISTOBJECT_H 2 # error "this header file must not be included directly" 3 #endif 4 5 #ifdef __cplusplus 6 extern "C" { 7 #endif 8 9 typedef struct { 10 PyObject_VAR_HEAD 11 /* Vector of pointers to list elements. list[0] is ob_item[0], etc. */ 12 PyObject **ob_item; 13 14 /* ob_item contains space for 'allocated' elements. The number 15 * currently in use is ob_size. 16 * Invariants: 17 * 0 <= ob_size <= allocated 18 * len(list) == ob_size 19 * ob_item == NULL implies ob_size == allocated == 0 20 * list.sort() temporarily sets allocated to -1 to detect mutations. 21 * 22 * Items must normally not be NULL, except during construction when 23 * the list is not yet visible outside the function that builds it. 24 */ 25 Py_ssize_t allocated; 26 } PyListObject; 27 28 PyAPI_FUNC(PyObject *) _PyList_Extend(PyListObject *, PyObject *); 29 PyAPI_FUNC(void) _PyList_DebugMallocStats(FILE *out); 30 31 /* Macro, trading safety for speed */ 32 33 /* Cast argument to PyTupleObject* type. */ 34 #define _PyList_CAST(op) (assert(PyList_Check(op)), (PyListObject *)(op)) 35 36 #define PyList_GET_ITEM(op, i) (_PyList_CAST(op)->ob_item[i]) 37 #define PyList_SET_ITEM(op, i, v) (_PyList_CAST(op)->ob_item[i] = (v)) 38 #define PyList_GET_SIZE(op) Py_SIZE(_PyList_CAST(op)) 39 #define _PyList_ITEMS(op) (_PyList_CAST(op)->ob_item) 40 41 #ifdef __cplusplus 42 } 43 #endif 44