Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:18:03

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     /* Vector of pointers to list elements.  list[0] is ob_item[0], etc. */
0008     PyObject **ob_item;
0009 
0010     /* ob_item contains space for 'allocated' elements.  The number
0011      * currently in use is ob_size.
0012      * Invariants:
0013      *     0 <= ob_size <= allocated
0014      *     len(list) == ob_size
0015      *     ob_item == NULL implies ob_size == allocated == 0
0016      * list.sort() temporarily sets allocated to -1 to detect mutations.
0017      *
0018      * Items must normally not be NULL, except during construction when
0019      * the list is not yet visible outside the function that builds it.
0020      */
0021     Py_ssize_t allocated;
0022 } PyListObject;
0023 
0024 PyAPI_FUNC(PyObject *) _PyList_Extend(PyListObject *, PyObject *);
0025 PyAPI_FUNC(void) _PyList_DebugMallocStats(FILE *out);
0026 
0027 /* Cast argument to PyListObject* type. */
0028 #define _PyList_CAST(op) \
0029     (assert(PyList_Check(op)), _Py_CAST(PyListObject*, (op)))
0030 
0031 // Macros and static inline functions, trading safety for speed
0032 
0033 static inline Py_ssize_t PyList_GET_SIZE(PyObject *op) {
0034     PyListObject *list = _PyList_CAST(op);
0035     return Py_SIZE(list);
0036 }
0037 #define PyList_GET_SIZE(op) PyList_GET_SIZE(_PyObject_CAST(op))
0038 
0039 #define PyList_GET_ITEM(op, index) (_PyList_CAST(op)->ob_item[(index)])
0040 
0041 static inline void
0042 PyList_SET_ITEM(PyObject *op, Py_ssize_t index, PyObject *value) {
0043     PyListObject *list = _PyList_CAST(op);
0044     list->ob_item[index] = value;
0045 }
0046 #define PyList_SET_ITEM(op, index, value) \
0047     PyList_SET_ITEM(_PyObject_CAST(op), (index), _PyObject_CAST(value))