Description
(See gh-100227.)
_Py_RefTotal
holds the current global total number of refcounts. It only exists if Py_REF_DEBUG
is defined (implied by Py_DEBUG
). It is exposed by sys.gettotalrefcount()
and set by Py_INCREF()
, Py_DECREF()
, etc. and _Py_NewReference()
.
Modications to _Py_RefTotal
are currently protected by the GIL so it should be moved to PyInterpreterState
. For various aspects of compatibility, it makes sense to keep the _Py_RefTotal
symbol around (and correct) and keep returning the global total from sys.gettotalrefcount()
.
Also, _Py_RefTotal
is used by stable ABI extensions only where Py_REF_DEBUG
is defined (unlikely) and only where built against 3.9 or earlier. Just in case, though, we must still keep the global variable around, so any solution here must respect that.
Linked PRs
- gh-102304: Consolidate Direct Usage of _Py_RefTotal #102514
- gh-102304: Move _Py_RefTotal to _PyRuntimeState #102543
- gh-102304: Move the Total Refcount to PyInterpreterState #102545
- gh-102304: Add a What's New Entry About _Py_RefTotal #102845
- gh-102304: Fix Non-Debug Builds #102846
- gh-102304: Fix 2 New Stable ABI Functions #104762
- gh-102304: Fix Py_INCREF() stable ABI in debug mode #104763
- gh-102304: Temporarily Bump Py_LIMITED_API for 2 New Functions #104766
- [3.12] gh-102304: Fix 2 New Stable ABI Functions (gh-104762) #105123
- gh-102304: doc: Add links to Stable ABI and Limited C API #105345
- [3.12] gh-102304: doc: Add links to Stable ABI and Limited C API (GH-105345) #105347
- gh-102304: Enhance Simple ABI doc #105351
- [3.12] gh-102304: Fix Py_INCREF() stable ABI in debug mode (#104763) #105352
- [3.12] gh-102304: doc: Add links to Stable ABI and Limited C API (#105345) #105371
- gh-102304: Document Py_INCREF() change in What's New in Python 3.12 #105389
- gh-102304: Debug mode no longer supports Limited API 3.9 #105391
- gh-102304: Fix Py_INCREF() for limited C API 3.9 #105550
- [3.12] gh-102304: Fix Py_INCREF() for limited C API 3.9 (GH-105550) #105551
- gh-102304: Remove Py_INCREF() doc change #105552
- [3.12] gh-102304: Fix Py_INCREF() for limited C API 3.9 #105553
- gh-102304: Rename _Py_IncRefTotal_DO_NOT_USE_THIS() #107193
- [3.12] gh-102304: Rename _Py_IncRefTotal_DO_NOT_USE_THIS() (GH-107193) #107199
- [3.11] gh-102304: doc: Add links to Stable ABI and Limited C API (#105345) (#105371) #109901
Metadata
Metadata
Assignees
Labels
Projects
Status