On Sun, 20 Mar 2016 at 09:44 Facundo Batista <facundobati...@gmail.com>
wrote:

> Hello!
>
> I'm seeing that our code increases the reference counting to Py_None,
> and I find this a little strange: isn't Py_None eternal and will never
> die?
>

Semantically yes, but we have to technically make that happen. :)


>
> What's the point of counting its references?
>

It's just another Python object, so if you return it then the code that
receives it may very well decref it because it always DECREFs the object
returned. And if we didn't keep its count accurately it would eventually
hit zero and constantly have its dealloc function checked for. We could add
a magical "never dies" value for the refcount, but that adds another `if`
branch in all the code instead of simply treating Py_None like any other
object and properly tracking its  reference.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to