<div dir="ltr">The older custom allocators may not bump the type's refcount when creating an instance.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 26, 2014 at 1:51 PM, Greg Ewing <span dir="ltr"><<a href="mailto:greg.ewing@canterbury.ac.nz" target="_blank">greg.ewing@canterbury.ac.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Nathaniel Smith wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This code has been around forever, but I don't know why. AFAIK we<br>
could replace the above with<br>
<br>
if (compatible_for_assignment(<u></u>oldto, newto, "__class__")) {<br>
if (newto->tp_flags & Py_TPFLAGS_HEAPTYPE) {<br>
Py_INCREF(newto);<br>
}<br>
Py_TYPE(self) = newto;<br>
if (oldto->tp_flags & Py_TPFLAGS_HEAPTYPE) {<br>
Py_DECREF(oldto);<br>
}<br>
return 0;<br>
}<br>
</blockquote>
<br></span>
Is it even necessary to worry about the refcounting?<br>
Presumably the non-heap type objects all start out with<br>
a refcount of at least 1, so there's no danger of them<br>
getting deallocated.<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Greg</font></span><div class="HOEnZb"><div class="h5"><br>
______________________________<u></u>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/<u></u>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/<u></u>codeofconduct/</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>--Guido van Rossum (<a href="http://python.org/~guido">python.org/~guido</a>)
</div>