Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Address review comments
  • Loading branch information
pgdr committed Oct 20, 2025
commit 48ca72af736022f7851ce6528e465dfd3d4cfe6d
2 changes: 0 additions & 2 deletions Lib/test/test_gc.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,8 +808,6 @@ def test_gc_debug_stats(self):
code = """if 1:
import gc
gc.set_debug(%s)
d = {}
d[(1,2)] = 1
gc.collect()
"""
_, _, err = assert_python_ok("-c", code % "gc.DEBUG_STATS")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Restore elapsed time and unreachable object count in GC debug output. These
were inadvertently removed during a refactor of ``gc.c``. The debug log now
again reports elapsed collection time and the number of unreachable objects.
Comment thread
efimov-mikhail marked this conversation as resolved.
Contributed by Pål Grønås Drange.
5 changes: 2 additions & 3 deletions Python/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "pycore_interpframe.h" // _PyFrame_GetLocalsArray()
#include "pycore_object_alloc.h" // _PyObject_MallocWithType()
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_time.h" // _PyTime_PerfCounterUnchecked()
#include "pycore_tuple.h" // _PyTuple_MaybeUntrack()
#include "pycore_weakref.h" // _PyWeakref_ClearRef()

Expand Down Expand Up @@ -2078,7 +2077,7 @@ _PyGC_Collect(PyThreadState *tstate, int generation, _PyGC_Reason reason)
if (reason != _Py_GC_REASON_SHUTDOWN) {
invoke_gc_callback(gcstate, "start", generation, &stats);
}
PyTime_t t1 = 0; /* initialize to prevent a compiler warning */
PyTime_t t1;
if (gcstate->debug & _PyGC_DEBUG_STATS) {
PySys_WriteStderr("gc: collecting generation %d...\n", generation);
(void)PyTime_PerfCounterRaw(&t1);
Expand Down Expand Up @@ -2120,7 +2119,7 @@ _PyGC_Collect(PyThreadState *tstate, int generation, _PyGC_Reason reason)
_Py_atomic_store_int(&gcstate->collecting, 0);

if (gcstate->debug & _PyGC_DEBUG_STATS) {
PyTime_t t2 = 0; /* initialize to prevent a compiler warning */
PyTime_t t2;
(void)PyTime_PerfCounterRaw(&t2);
double d = PyTime_AsSecondsDouble(t2 - t1);
PySys_WriteStderr(
Expand Down
Loading