mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Be smarter about clearing the weakref lists for instances, instance methods,
and functions: we only need to call PyObject_ClearWeakRefs() if the weakref list is non-NULL. Since these objects are common but weakrefs are still unusual, saving the call at deallocation time makes a lot of sense.
This commit is contained in:
parent
7408da54e2
commit
c916f5a390
2 changed files with 6 additions and 3 deletions
|
@ -270,7 +270,8 @@ static void
|
|||
func_dealloc(PyFunctionObject *op)
|
||||
{
|
||||
_PyObject_GC_UNTRACK(op);
|
||||
PyObject_ClearWeakRefs((PyObject *) op);
|
||||
if (op->func_weakreflist != NULL)
|
||||
PyObject_ClearWeakRefs((PyObject *) op);
|
||||
Py_DECREF(op->func_code);
|
||||
Py_DECREF(op->func_globals);
|
||||
Py_DECREF(op->func_name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue