26 Sep
2014
26 Sep
'14
1:51 p.m.
Nathaniel Smith wrote:
This code has been around forever, but I don't know why. AFAIK we could replace the above with
if (compatible_for_assignment(oldto, newto, "__class__")) { if (newto->tp_flags & Py_TPFLAGS_HEAPTYPE) { Py_INCREF(newto); } Py_TYPE(self) = newto; if (oldto->tp_flags & Py_TPFLAGS_HEAPTYPE) { Py_DECREF(oldto); } return 0; }
Is it even necessary to worry about the refcounting? Presumably the non-heap type objects all start out with a refcount of at least 1, so there's no danger of them getting deallocated. -- Greg