Test 0 and false since false is 0
On Tue, 11 Jul 2017 11:16 pm, Albert-Jan Roskam wrote:
> >>> False == 0
> >>> False is 0
> =====> Just wondering: Is this 'is' test depending on an implementation detail
> of cPython (small ints, I forgot how small 0-255 maybe, are singletons)?
No. But the test 0 is 0 will be.
True and False are guaranteed singletons: there will only ever be a single
The small ints including 0 *may* be cached, so that they will be singletons. The
definition of "small" will vary from version to version.
?Cheer up,? they said, ?things could be worse.? So I cheered up, and sure
enough, things got worse.