diff options
author | Collin Winter <collinw@gmail.com> | 2010-03-18 21:54:01 (GMT) |
---|---|---|
committer | Collin Winter <collinw@gmail.com> | 2010-03-18 21:54:01 (GMT) |
commit | 001a3952c973c645d961b4d688fc79d556fd580d (patch) | |
tree | 79213b980c9beda258b833ac5274b23c98d20084 /Objects | |
parent | 2e0a53fdf6dd84ab5418ae4faec330eaed443bd6 (diff) | |
download | cpython-001a3952c973c645d961b4d688fc79d556fd580d.zip cpython-001a3952c973c645d961b4d688fc79d556fd580d.tar.gz cpython-001a3952c973c645d961b4d688fc79d556fd580d.tar.bz2 |
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!
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/codeobject.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 6d6775a..340cef0 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -103,6 +103,7 @@ PyCode_New(int argcount, int nlocals, int stacksize, int flags, Py_INCREF(lnotab); co->co_lnotab = lnotab; co->co_zombieframe = NULL; + co->co_weakreflist = NULL; } return co; } @@ -314,6 +315,8 @@ code_dealloc(PyCodeObject *co) 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); } @@ -490,8 +493,8 @@ PyTypeObject PyCode_Type = { code_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - code_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ + code_richcompare, /* tp_richcompare */ + offsetof(PyCodeObject, co_weakreflist), /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ |