Re: [Python-Dev] peps: document requirements
On Mon, 30 Sep 2013 17:08:00 +0200 (CEST) christian.heimes <python-checkins@python.org> wrote:
+ +* It should return ``0`` for zero length input. (Note: This can be handled as + special case, too.)
What is this required for? The main requirement is that equal stuff hashes equal, but there's no reason for zero-length input to hash to zero, AFAIK. Regards Antoine.
Am 30.09.2013 20:16, schrieb Antoine Pitrou:
On Mon, 30 Sep 2013 17:08:00 +0200 (CEST) christian.heimes <python-checkins@python.org> wrote:
+ +* It should return ``0`` for zero length input. (Note: This can be handled as + special case, too.)
What is this required for? The main requirement is that equal stuff hashes equal, but there's no reason for zero-length input to hash to zero, AFAIK.
http://hg.python.org/cpython/file/d7ba4ca59023/Objects/object.c#l852 We make the hash of the empty string be 0, rather than using (prefix ^ suffix), since this slightly obfuscates the hash secret It's not a hard requirement, hence 'should' instead of 'must' like in all other cases. Christian
participants (2)
-
Antoine Pitrou -
Christian Heimes