mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
gh-102304: Move _Py_RefTotal to _PyRuntimeState (gh-102543)
The essentially eliminates the global variable, with the associated benefits. This is also a precursor to isolating this bit of state to PyInterpreterState. Folks that currently read _Py_RefTotal directly would have to start using _Py_GetGlobalRefTotal() instead. https://github.com/python/cpython/issues/102304
This commit is contained in:
parent
96e05b62e8
commit
ad77d16a62
13 changed files with 132 additions and 47 deletions
|
@ -1930,6 +1930,7 @@ Py_FinalizeEx(void)
|
|||
if (show_ref_count) {
|
||||
_PyDebug_PrintTotalRefs();
|
||||
}
|
||||
_Py_FinalizeRefTotal(runtime);
|
||||
#endif
|
||||
|
||||
#ifdef Py_TRACE_REFS
|
||||
|
|
|
@ -482,6 +482,9 @@ _PyRuntimeState_Init(_PyRuntimeState *runtime)
|
|||
void
|
||||
_PyRuntimeState_Fini(_PyRuntimeState *runtime)
|
||||
{
|
||||
/* The reftotal is cleared by _Py_FinalizeRefTotal(). */
|
||||
assert(runtime->object_state.reftotal == 0);
|
||||
|
||||
if (gilstate_tss_initialized(runtime)) {
|
||||
gilstate_tss_fini(runtime);
|
||||
}
|
||||
|
|
|
@ -1854,7 +1854,7 @@ static Py_ssize_t
|
|||
sys_gettotalrefcount_impl(PyObject *module)
|
||||
/*[clinic end generated code: output=4103886cf17c25bc input=53b744faa5d2e4f6]*/
|
||||
{
|
||||
return _Py_GetRefTotal();
|
||||
return _Py_GetGlobalRefTotal();
|
||||
}
|
||||
|
||||
#endif /* Py_REF_DEBUG */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue