[Python-ideas] Implicit submodule imports
Guido van Rossum
guido at python.org
Fri Sep 26 22:56:49 CEST 2014
The older custom allocators may not bump the type's refcount when creating
an instance.
On Fri, Sep 26, 2014 at 1:51 PM, Greg Ewing <greg.ewing at canterbury.ac.nz>
wrote:
> 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
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
--
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140926/9b8bf481/attachment-0001.html>
More information about the Python-ideas
mailing list