Message141269
| Author |
rhettinger |
| Recipients |
rhettinger |
| Date |
2011年07月27日.19:26:16 |
| SpamBayes Score |
1.3898632e-08 |
| Marked as misclassified |
No |
| Message-id |
<1311794776.71.0.254853675833.issue12647@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2011年07月27日 19:26:16 | rhettinger | set | recipients:
+ rhettinger |
| 2011年07月27日 19:26:16 | rhettinger | set | messageid: <1311794776.71.0.254853675833.issue12647@psf.upfronthosting.co.za> |
| 2011年07月27日 19:26:16 | rhettinger | link | issue12647 messages |
| 2011年07月27日 19:26:16 | rhettinger | create |
|