New submission from Raymond Hettinger <raymond.hettin...@gmail.com>:
Currently bool(None) returns False only because it has a special case in PyObject_IsTrue(). All other types can become False only if they implement __bool__() or __len__(). I propose removing the special case branch and instead adding __bool__ to None. This will simplify the explanation of what bool() does to: "bool(x) always returns True unless the object defines __bool__() to return False or defines __len__() to return a non-zero value". The removal of the special case will slightly slow down tests for "if None", and it will slightly speed-up tests for "if x" where x is something other than True, False, or None. ---------- assignee: rhettinger components: Interpreter Core messages: 141269 nosy: rhettinger priority: low severity: normal status: open title: Add __bool__ to None versions: Python 3.3 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12647> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com