Re: [Python-Dev] Hashes in Python3.5 for tuples and frozensets

2018-05-17 Thread Chris Angelico
On Fri, May 18, 2018 at 12:15 AM, Anthony Flury via Python-Dev wrote: > Chris, > I entirely agree. The same questioner also asked about the fastest data type > to use as a key in a dictionary; and which data structure is fastest. I get > the impression the person is very into micro-optimization, w

Re: [Python-Dev] Hashes in Python3.5 for tuples and frozensets

2018-05-17 Thread Anthony Flury via Python-Dev
Chris, I entirely agree. The same questioner also asked about the fastest data type to use as a key in a dictionary; and which data structure is fastest. I get the impression the person is very into micro-optimization, without profiling their application. It seems every choice is made based on

Re: [Python-Dev] Hashes in Python3.5 for tuples and frozensets

2018-05-17 Thread Chris Angelico
On Thu, May 17, 2018 at 5:21 PM, Anthony Flury via Python-Dev wrote: > Victor, > Thanks for the link, but to be honest it will just confuse people - neither > the link or the related bpo entries state that the fix is only limited to > strings. They simply talk about hash randomization - which in m

Re: [Python-Dev] Hashes in Python3.5 for tuples and frozensets

2018-05-17 Thread Greg Ewing
Anthony Flury via Python-Dev wrote: //I did suggest strongly to the original questioner that relying on the same hash value across different platforms wasn't a clever solution Even without randomisation, I wouldn't rely on hash values staying the same between different Python versions. Storing

Re: [Python-Dev] Hashes in Python3.5 for tuples and frozensets

2018-05-17 Thread Anthony Flury via Python-Dev
Victor, Thanks for the link, but to be honest it will just confuse people - neither the link or the related bpo entries state that the fix is only limited to strings. They simply talk about hash randomization - which in my opinion implies ALL hash algorithms; which is why I asked the question.

Re: [Python-Dev] Hashes in Python3.5 for tuples and frozensets

2018-05-16 Thread Victor Stinner
Hi, String hash is randomized, but not the integer hash: $ python3.5 -c 'print(hash("abc"))' -8844814677999896014 $ python3.5 -c 'print(hash("abc"))' -7757160699952389646 $ python3.5 -c 'print(hash(1))' 1 $ python3.5 -c 'print(hash(1))' 1 frozenset hash is combined from values of the set. So it

Re: [Python-Dev] Hashes in Python3.5 for tuples and frozensets

2018-05-16 Thread Christian Heimes
On 2018-05-16 18:10, Raymond Hettinger wrote: > > >> On May 16, 2018, at 5:48 PM, Anthony Flury via Python-Dev >> wrote: >> >> However the frozen set hash, the same in both cases, as is the hash of the >> tuples - suggesting that the vulnerability resolved in Python 3.3 wasn't >> resolved acr

Re: [Python-Dev] Hashes in Python3.5 for tuples and frozensets

2018-05-16 Thread Raymond Hettinger
> On May 16, 2018, at 5:48 PM, Anthony Flury via Python-Dev > wrote: > > However the frozen set hash, the same in both cases, as is the hash of the > tuples - suggesting that the vulnerability resolved in Python 3.3 wasn't > resolved across all potentially hashable values. You are correct.

[Python-Dev] Hashes in Python3.5 for tuples and frozensets

2018-05-16 Thread Anthony Flury via Python-Dev
This may be known but I wanted to ask this esteemed body first. I understand that from Python3.3 there was a security fix to ensure that different python processes would generate different hash value for the same input - to prevent denial of service based on crafted hash conflicts. I opened t