Skip to content

Commit 63c0e3e

Browse files
Revert GC changes
1 parent 30dd590 commit 63c0e3e

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

Include/internal/pycore_gc.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ static inline void _PyObject_GC_TRACK(
240240

241241
PyInterpreterState *interp = _PyInterpreterState_GET();
242242
PyGC_Head *generation0 = &interp->gc.young.head;
243-
interp->gc.young.count++; /* number of tracked GC objects */
244243
PyGC_Head *last = (PyGC_Head*)(generation0->_gc_prev);
245244
_PyGCHead_SET_NEXT(last, gc);
246245
_PyGCHead_SET_PREV(gc, last);
@@ -281,10 +280,6 @@ static inline void _PyObject_GC_UNTRACK(
281280
_PyGCHead_SET_PREV(next, prev);
282281
gc->_gc_next = 0;
283282
gc->_gc_prev &= _PyGC_PREV_MASK_FINALIZED;
284-
PyInterpreterState *interp = _PyInterpreterState_GET();
285-
if (interp->gc.young.count > 0) {
286-
interp->gc.young.count--;
287-
}
288283
#endif
289284
}
290285

Objects/tupleobject.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ _PyTuple_MaybeUntrack(PyObject *op)
156156
_PyObject_GC_UNTRACK(op);
157157
}
158158

159-
//
160159
static bool
161160
tuple_need_tracking(PyTupleObject *self)
162161
{

Python/gc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2296,6 +2296,7 @@ _PyObject_GC_Link(PyObject *op)
22962296
GCState *gcstate = &tstate->interp->gc;
22972297
gc->_gc_next = 0;
22982298
gc->_gc_prev = 0;
2299+
gcstate->young.count++; /* number of allocated GC objects */
22992300
gcstate->heap_size++;
23002301
if (gcstate->young.count > gcstate->young.threshold &&
23012302
gcstate->enabled &&
@@ -2427,6 +2428,9 @@ PyObject_GC_Del(void *op)
24272428
#endif
24282429
}
24292430
GCState *gcstate = get_gc_state();
2431+
if (gcstate->young.count > 0) {
2432+
gcstate->young.count--;
2433+
}
24302434
gcstate->heap_size--;
24312435
PyObject_Free(((char *)op)-presize);
24322436
}

0 commit comments

Comments
 (0)