[Python-ideas] Implicit submodule imports
Greg Ewing
greg.ewing at canterbury.ac.nz
Fri Sep 26 22:51:20 CEST 2014
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
More information about the Python-ideas
mailing list