Message349865
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. |
|
Date |
User |
Action |
Args |
2019-08-16 14:20:11 | tim.peters | set | recipients:
+ tim.peters, lemburg, rhettinger, mark.dickinson, belopolsky, christian.heimes, benjamin.peterson, dmalcolm, serhiy.storchaka, epicfaace |
2019-08-16 14:20:11 | tim.peters | set | messageid: <1565965211.34.0.594759949438.issue29535@roundup.psfhosted.org> |
2019-08-16 14:20:11 | tim.peters | link | issue29535 messages |
2019-08-16 14:20:10 | tim.peters | create | |
|