Files
typthon/Include/cpython/listobject.h
copilot-swe-agent[bot] b198f511d2 Rename Py_ to Ty_ throughout C API
Massive automated renaming of all Py_/PyObject/etc. prefixes to Ty_/TyObject/etc.
This includes:
- All public API types (TyObject, TyTypeObject, etc.)
- All public API functions (Ty_Initialize, Ty_BuildValue, etc.)
- All internal API (_Ty_ prefixes)
- Reference counting macros (Ty_INCREF, Ty_DECREF, etc.)
- Type flags (Ty_TPFLAGS_*)
- Debug flags (Ty_DEBUG, Ty_TRACE_REFS, etc.)
- All object type APIs (TyList_, TyDict_, TyUnicode_, etc.)

This changes over 60,000 occurrences across 1000+ files.

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
2025-12-29 17:37:49 +00:00

54 lines
1.8 KiB
C

#ifndef Ty_CPYTHON_LISTOBJECT_H
# error "this header file must not be included directly"
#endif
typedef struct {
PyObject_VAR_HEAD
/* Vector of pointers to list elements. list[0] is ob_item[0], etc. */
TyObject **ob_item;
/* ob_item contains space for 'allocated' elements. The number
* currently in use is ob_size.
* Invariants:
* 0 <= ob_size <= allocated
* len(list) == ob_size
* ob_item == NULL implies ob_size == allocated == 0
* list.sort() temporarily sets allocated to -1 to detect mutations.
*
* Items must normally not be NULL, except during construction when
* the list is not yet visible outside the function that builds it.
*/
Ty_ssize_t allocated;
} PyListObject;
/* Cast argument to PyListObject* type. */
#define _TyList_CAST(op) \
(assert(TyList_Check(op)), _Ty_CAST(PyListObject*, (op)))
// Macros and static inline functions, trading safety for speed
static inline Ty_ssize_t TyList_GET_SIZE(TyObject *op) {
PyListObject *list = _TyList_CAST(op);
#ifdef Ty_GIL_DISABLED
return _Ty_atomic_load_ssize_relaxed(&(_PyVarObject_CAST(list)->ob_size));
#else
return Ty_SIZE(list);
#endif
}
#define TyList_GET_SIZE(op) TyList_GET_SIZE(_TyObject_CAST(op))
#define TyList_GET_ITEM(op, index) (_TyList_CAST(op)->ob_item[(index)])
static inline void
TyList_SET_ITEM(TyObject *op, Ty_ssize_t index, TyObject *value) {
PyListObject *list = _TyList_CAST(op);
assert(0 <= index);
assert(index < list->allocated);
list->ob_item[index] = value;
}
#define TyList_SET_ITEM(op, index, value) \
TyList_SET_ITEM(_TyObject_CAST(op), (index), _TyObject_CAST(value))
PyAPI_FUNC(int) TyList_Extend(TyObject *self, TyObject *iterable);
PyAPI_FUNC(int) TyList_Clear(TyObject *self);