Where Online Learning is simpler!
The C and C++ Include Header Files
/usr/include/python3.12/internal/pycore_list.h
$ cat -n /usr/include/python3.12/internal/pycore_list.h 1 #ifndef Py_INTERNAL_LIST_H 2 #define Py_INTERNAL_LIST_H 3 #ifdef __cplusplus 4 extern "C" { 5 #endif 6 7 #ifndef Py_BUILD_CORE 8 # error "this header requires Py_BUILD_CORE define" 9 #endif 10 11 #include "listobject.h" // _PyList_CAST() 12 13 14 /* runtime lifecycle */ 15 16 extern void _PyList_Fini(PyInterpreterState *); 17 18 19 /* other API */ 20 21 #ifndef WITH_FREELISTS 22 // without freelists 23 # define PyList_MAXFREELIST 0 24 #endif 25 26 /* Empty list reuse scheme to save calls to malloc and free */ 27 #ifndef PyList_MAXFREELIST 28 # define PyList_MAXFREELIST 80 29 #endif 30 31 struct _Py_list_state { 32 #if PyList_MAXFREELIST > 0 33 PyListObject *free_list[PyList_MAXFREELIST]; 34 int numfree; 35 #endif 36 }; 37 38 #define _PyList_ITEMS(op) _Py_RVALUE(_PyList_CAST(op)->ob_item) 39 40 extern int 41 _PyList_AppendTakeRefListResize(PyListObject *self, PyObject *newitem); 42 43 static inline int 44 _PyList_AppendTakeRef(PyListObject *self, PyObject *newitem) 45 { 46 assert(self != NULL && newitem != NULL); 47 assert(PyList_Check(self)); 48 Py_ssize_t len = PyList_GET_SIZE(self); 49 Py_ssize_t allocated = self->allocated; 50 assert((size_t)len + 1 < PY_SSIZE_T_MAX); 51 if (allocated > len) { 52 PyList_SET_ITEM(self, len, newitem); 53 Py_SET_SIZE(self, len + 1); 54 return 0; 55 } 56 return _PyList_AppendTakeRefListResize(self, newitem); 57 } 58 59 // Repeat the bytes of a buffer in place 60 static inline void 61 _Py_memory_repeat(char* dest, Py_ssize_t len_dest, Py_ssize_t len_src) 62 { 63 assert(len_src > 0); 64 Py_ssize_t copied = len_src; 65 while (copied < len_dest) { 66 Py_ssize_t bytes_to_copy = Py_MIN(copied, len_dest - copied); 67 memcpy(dest + copied, dest, bytes_to_copy); 68 copied += bytes_to_copy; 69 } 70 } 71 72 typedef struct { 73 PyObject_HEAD 74 Py_ssize_t it_index; 75 PyListObject *it_seq; /* Set to NULL when iterator is exhausted */ 76 } _PyListIterObject; 77 78 extern PyObject *_PyList_FromArraySteal(PyObject *const *src, Py_ssize_t n); 79 80 #ifdef __cplusplus 81 } 82 #endif 83 #endif /* !Py_INTERNAL_LIST_H */
Contact us
|
About us
|
Term of use
|
Copyright © 2000-2025 MyWebUniversity.com ™