Mark Dickinson added the comment: "Apparently True and 1 hash to the same item and False and 0 hash to the same item"
Just to clear up a possible misconception here, the key point here is not that they hash to the same integer, but that they're *equal*: >>> True == 1 True >>> False == 0 True In contrast, here are two elements whose hash is equal but which serve as distinct keys: >>> hash(-1) == hash(-2) True >>> len({-1: -1, -2: -2}) 2 IOW, dictionary semantics are defined in terms of equality, not hashing. The hashing part should really be thought of as just a (somewhat exposed) implementation detail. ---------- nosy: +mark.dickinson _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26614> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com