File indexing completed on 2025-11-19 09:50:41
0001 #ifndef Py_CPYTHON_LISTOBJECT_H
0002 # error "this header file must not be included directly"
0003 #endif
0004
0005 typedef struct {
0006 PyObject_VAR_HEAD
0007
0008 PyObject **ob_item;
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 Py_ssize_t allocated;
0022 } PyListObject;
0023
0024
0025 #define _PyList_CAST(op) \
0026 (assert(PyList_Check(op)), _Py_CAST(PyListObject*, (op)))
0027
0028
0029
0030 static inline Py_ssize_t PyList_GET_SIZE(PyObject *op) {
0031 PyListObject *list = _PyList_CAST(op);
0032 #ifdef Py_GIL_DISABLED
0033 return _Py_atomic_load_ssize_relaxed(&(_PyVarObject_CAST(list)->ob_size));
0034 #else
0035 return Py_SIZE(list);
0036 #endif
0037 }
0038 #define PyList_GET_SIZE(op) PyList_GET_SIZE(_PyObject_CAST(op))
0039
0040 #define PyList_GET_ITEM(op, index) (_PyList_CAST(op)->ob_item[(index)])
0041
0042 static inline void
0043 PyList_SET_ITEM(PyObject *op, Py_ssize_t index, PyObject *value) {
0044 PyListObject *list = _PyList_CAST(op);
0045 assert(0 <= index);
0046 assert(index < list->allocated);
0047 list->ob_item[index] = value;
0048 }
0049 #define PyList_SET_ITEM(op, index, value) \
0050 PyList_SET_ITEM(_PyObject_CAST(op), (index), _PyObject_CAST(value))
0051
0052 PyAPI_FUNC(int) PyList_Extend(PyObject *self, PyObject *iterable);
0053 PyAPI_FUNC(int) PyList_Clear(PyObject *self);