Tim Peters <t...@python.org> added the comment:

I'm with Mark:  leave numeric hashes alone.  There's no reason to change them, 
and in addition to what Mark wrote it's a positively Good Thing that `hash(i) 
== i` for all sufficiently small ints.  Not only is that efficient to compute, 
it guarantees there are no collisions _at all_ in the common case of a dict 
indexed by a contiguous range of integers.

The _purpose_ of `hash()` in Python isn't to create an illusion of randomness, 
it's to support efficient dicts and sets.  Mucking with string hashes was a 
pragmatic hack to alleviate concerns about DOS attacks specific to 
string-indexed dicts.  A better technical solution to that would have been to 
introduce a different flavor of dict with guaranteed good worst-case behaviors, 
but, pragmatically, a great many users would never realize that's what they 
really wanted, and it wouldn't have helped pre-existing code at all.

But there's no reason to spread that hack beyond the use cases that needed it, 
and much reason not to.

----------
nosy: +tim.peters

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue29535>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to