Why does Python keep a reference count on False and True? Why does Python keep a reference count on False and True? python python

Why does Python keep a reference count on False and True?


It's to make all object handling uniform. If I'm writing C code that handles a return value from a function, I have to increment and decrement the reference count on that object. If the function returns me True, I don't want to have to check to see if it's one of those special objects to know whether to manipulate its reference count. I can treat all objects identically.

By treating True and False (and None, btw) the same as all other objects, the C code is much simpler throughout.