Mercurial > cpython-lru_cache-weakref
diff Objects/codeobject.c @ 59705:eea72b81a23c
Merged revisions 79060 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79060 | collin.winter | 2010-03-18 14:54:01 -0700 (Thu, 18 Mar 2010) | 4 lines
Add support for weak references to code objects. This will be used by an optimization in the incoming Python 3 JIT.
Patch by Reid Kleckner!
........
| author | Collin Winter <collinw@gmail.com> |
|---|---|
| date | Thu, 18 Mar 2010 22:46:40 +0000 |
| parents | 79718ee03986 |
| children | 0b0971daf58c |
line wrap: on
line diff
--- a/Objects/codeobject.c Thu Mar 18 22:43:41 2010 +0000 +++ b/Objects/codeobject.c Thu Mar 18 22:46:40 2010 +0000 @@ -108,6 +108,7 @@ Py_INCREF(lnotab); co->co_lnotab = lnotab; co->co_zombieframe = NULL; + co->co_weakreflist = NULL; } return co; } @@ -331,6 +332,8 @@ Py_XDECREF(co->co_lnotab); if (co->co_zombieframe != NULL) PyObject_GC_Del(co->co_zombieframe); + if (co->co_weakreflist != NULL) + PyObject_ClearWeakRefs((PyObject*)co); PyObject_DEL(co); } @@ -462,7 +465,7 @@ 0, /* tp_traverse */ 0, /* tp_clear */ code_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ + offsetof(PyCodeObject, co_weakreflist), /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */
