This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: frozenset.__hash__ vs. Set._hash
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Dennis Sweeney, Prometheus3375, miss-islington, rhettinger
Priority: normal Keywords: patch

Created on 2021-07-21 21:32 by Prometheus3375, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 27281 merged Dennis Sweeney, 2021-07-21 23:14
PR 27282 merged miss-islington, 2021-07-21 23:49
PR 27283 merged miss-islington, 2021-07-21 23:49
Messages (4)
msg397963 - (view) Author: Svyatoslav (Prometheus3375) * Date: 2021-07-21 21:32
In docstring of Set._hash in _collections_abc.py is written:
"We match the algorithm used by the built-in frozenset type."

But
>>> s = frozenset({i for i in range(10)})
>>> hash(s)
3895031357313128696
>>> Set._hash(s)
3914343279946282847

Looks like Set._hash is different.
msg397968 - (view) Author: Dennis Sweeney (Dennis Sweeney) * (Python committer) Date: 2021-07-21 23:21
I opened a PR. It looks like frozenset.__hash__ changed in GH-5194 and GH-5235, but Set._hash wasn't updated accordingly.
msg397970 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-07-21 23:49
New changeset c878f5d81772dc6f718d6608c78baa4be9a4f176 by Dennis Sweeney in branch 'main':
bpo-44704: Make Set._hash consistent with frozenset.__hash__ (GH-27281)
https://github.com/python/cpython/commit/c878f5d81772dc6f718d6608c78baa4be9a4f176
msg397972 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-07-22 00:23
New changeset e0ef81600f4331299f61bbe3f7f08bb21d90315b by Miss Islington (bot) in branch '3.9':
bpo-44704: Make Set._hash consistent with frozenset.__hash__ (GH-27281) (GH-27283)
https://github.com/python/cpython/commit/e0ef81600f4331299f61bbe3f7f08bb21d90315b
msg397973 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-07-22 00:23
New changeset 4194f1465fa85371dcbead57a54bb06d1f0b97d9 by Miss Islington (bot) in branch '3.10':
bpo-44704: Make Set._hash consistent with frozenset.__hash__ (GH-27281) (GH-27282)
https://github.com/python/cpython/commit/4194f1465fa85371dcbead57a54bb06d1f0b97d9
History
Date User Action Args
2022-04-11 14:59:47adminsetgithub: 88870
2021-07-22 00:23:47rhettingersetmessages: + msg397973
2021-07-22 00:23:47rhettingersetmessages: + msg397972
2021-07-21 23:59:44rhettingersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-07-21 23:49:36miss-islingtonsetpull_requests: + pull_request25827
2021-07-21 23:49:30miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request25826
2021-07-21 23:49:12rhettingersetnosy: + rhettinger
messages: + msg397970
2021-07-21 23:21:27Dennis Sweeneysetmessages: + msg397968
2021-07-21 23:14:58Dennis Sweeneysetkeywords: + patch
nosy: + Dennis Sweeney

pull_requests: + pull_request25825
stage: patch review
2021-07-21 21:32:14Prometheus3375create