Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/python3.14/internal/pycore_uniqueid.h
1 #ifndef Py_INTERNAL_UNIQUEID_H 2 #define Py_INTERNAL_UNIQUEID_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 #ifdef Py_GIL_DISABLED 12 13 // This contains code for allocating unique ids to objects for per-thread 14 // reference counting. 15 // 16 // Per-thread reference counting is used along with deferred reference 17 // counting to avoid scaling bottlenecks due to reference count contention. 18 // 19 // An id of 0 is used to indicate that an object doesn't use per-thread 20 // refcounting. This value is used when the object is finalized by the GC 21 // and during interpreter shutdown to allow the object to be 22 // deallocated promptly when the object's refcount reaches zero. 23 // 24 // Each entry implicitly represents a unique id based on its offset in the 25 // table. Non-allocated entries form a free-list via the 'next' pointer. 26 // Allocated entries store the corresponding PyObject. 27 28 #define _Py_INVALID_UNIQUE_ID 0 29 30 // Assigns the next id from the pool of ids. 31 extern Py_ssize_t _PyObject_AssignUniqueId(PyObject *obj); 32 33 // Releases the allocated id back to the pool. 34 extern void _PyObject_ReleaseUniqueId(Py_ssize_t unique_id); 35 36 // Releases the allocated id back to the pool. 37 extern void _PyObject_DisablePerThreadRefcounting(PyObject *obj); 38 39 // Merges the per-thread reference counts into the corresponding objects. 40 extern void _PyObject_MergePerThreadRefcounts(_PyThreadStateImpl *tstate); 41 42 // Like _PyObject_MergePerThreadRefcounts, but also frees the per-thread 43 // array of refcounts. 44 extern void _PyObject_FinalizePerThreadRefcounts(_PyThreadStateImpl *tstate); 45 46 // Frees the interpreter's pool of type ids. 47 extern void _PyObject_FinalizeUniqueIdPool(PyInterpreterState *interp); 48 49 // Increfs the object, resizing the thread-local refcount array if necessary. 50 PyAPI_FUNC(void) _PyObject_ThreadIncrefSlow(PyObject *obj, size_t idx); 51 52 #endif /* Py_GIL_DISABLED */ 53 54 #ifdef __cplusplus 55 } 56 #endif 57 #endif /* !Py_INTERNAL_UNIQUEID_H */