Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 82f1480

Browse files
committed
Inform the cycle-detector that the a weakref object no longer needs to be
tracked as soon as it is clear; this can decrease the number of roots for the cycle detector sooner rather than later in applications which hold on to weak references beyond the time of the invalidation.
1 parent 2c77355 commit 82f1480

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Modules/_weakref.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ clear_weakref(PyWeakReference *self)
5959
if (self->wr_object != Py_None) {
6060
PyWeakReference **list = GET_WEAKREFS_LISTPTR(self->wr_object);
6161

62+
PyObject_GC_Fini((PyObject *)self);
6263
if (*list == self)
6364
*list = self->wr_next;
6465
self->wr_object = Py_None;
@@ -78,7 +79,6 @@ static void
7879
weakref_dealloc(PyWeakReference *self)
7980
{
8081
clear_weakref(self);
81-
PyObject_GC_Fini((PyObject *)self);
8282
self->wr_next = free_list;
8383
free_list = self;
8484
}

0 commit comments

Comments
 (0)