(original) (raw)



On Sun, 20 Mar 2016 at 09:44 Facundo Batista <facundobatista@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.