comparison 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
comparison
equal deleted inserted replaced
59703:4f09d5b1475f 59705:eea72b81a23c
106 co->co_name = name; 106 co->co_name = name;
107 co->co_firstlineno = firstlineno; 107 co->co_firstlineno = firstlineno;
108 Py_INCREF(lnotab); 108 Py_INCREF(lnotab);
109 co->co_lnotab = lnotab; 109 co->co_lnotab = lnotab;
110 co->co_zombieframe = NULL; 110 co->co_zombieframe = NULL;
111 co->co_weakreflist = NULL;
111 } 112 }
112 return co; 113 return co;
113 } 114 }
114 115
115 PyCodeObject * 116 PyCodeObject *
329 Py_XDECREF(co->co_filename); 330 Py_XDECREF(co->co_filename);
330 Py_XDECREF(co->co_name); 331 Py_XDECREF(co->co_name);
331 Py_XDECREF(co->co_lnotab); 332 Py_XDECREF(co->co_lnotab);
332 if (co->co_zombieframe != NULL) 333 if (co->co_zombieframe != NULL)
333 PyObject_GC_Del(co->co_zombieframe); 334 PyObject_GC_Del(co->co_zombieframe);
335 if (co->co_weakreflist != NULL)
336 PyObject_ClearWeakRefs((PyObject*)co);
334 PyObject_DEL(co); 337 PyObject_DEL(co);
335 } 338 }
336 339
337 static PyObject * 340 static PyObject *
338 code_repr(PyCodeObject *co) 341 code_repr(PyCodeObject *co)
460 Py_TPFLAGS_DEFAULT, /* tp_flags */ 463 Py_TPFLAGS_DEFAULT, /* tp_flags */
461 code_doc, /* tp_doc */ 464 code_doc, /* tp_doc */
462 0, /* tp_traverse */ 465 0, /* tp_traverse */
463 0, /* tp_clear */ 466 0, /* tp_clear */
464 code_richcompare, /* tp_richcompare */ 467 code_richcompare, /* tp_richcompare */
465 0, /* tp_weaklistoffset */ 468 offsetof(PyCodeObject, co_weakreflist), /* tp_weaklistoffset */
466 0, /* tp_iter */ 469 0, /* tp_iter */
467 0, /* tp_iternext */ 470 0, /* tp_iternext */
468 0, /* tp_methods */ 471 0, /* tp_methods */
469 code_memberlist, /* tp_members */ 472 code_memberlist, /* tp_members */
470 0, /* tp_getset */ 473 0, /* tp_getset */