Issue 14815: random_seed uses only 32-bits of hash on Win64 (original) (raw)
Issue14815
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.
This issue has been migrated to GitHub: https://github.com/python/cpython/issues/59020
classification
Title: | random_seed uses only 32-bits of hash on Win64 | ||
---|---|---|---|
Type: | enhancement | Stage: | commit review |
Components: | Versions: |
process
Status: | closed | Resolution: | fixed |
---|---|---|---|
Dependencies: | Superseder: | ||
Assigned To: | loewis | Nosy List: | larry, loewis, python-dev, rhettinger, serhiy.storchaka |
Priority: | normal | Keywords: | patch |
Created on 2012-05-15 12:23 by loewis, last changed 2022-04-11 14:57 by admin. This issue is now closed.
Files | |||
---|---|---|---|
File name | Uploaded | Description | Edit |
larry.random_seed.ssize_t.1.diff | larry,2012-06-24 06:01 | review |
Messages (6) | ||
---|---|---|
msg160720 - (view) | Author: Martin v. Löwis (loewis) * ![]() |
Date: 2012-05-15 12:23 |
random_seed has this code: long hash = PyObject_Hash(arg); On Win64, Py_hash_t is a 64-bit type, yet long is a 32-bit type, so this truncates. I think the computation should be done in Py_ssize_t. | ||
msg160880 - (view) | Author: Raymond Hettinger (rhettinger) * ![]() |
Date: 2012-05-16 16:33 |
This is a reasonable change. The benefits of using all 64-bits outweigh the small downside of losing the reproducibility of previously generated sequences that relied on the object hash. | ||
msg163719 - (view) | Author: Larry Hastings (larry) * ![]() |
Date: 2012-06-24 06:01 |
I got bored so I made you a patch. | ||
msg163737 - (view) | Author: Martin v. Löwis (loewis) * ![]() |
Date: 2012-06-24 06:56 |
LGTM | ||
msg163752 - (view) | Author: Roundup Robot (python-dev) ![]() |
Date: 2012-06-24 08:54 |
New changeset 166599219bd4 by Larry Hastings in branch 'default': Issue #14815: Use Py_ssize_t instead of long for the object hash, to http://hg.python.org/cpython/rev/166599219bd4 | ||
msg163758 - (view) | Author: Roundup Robot (python-dev) ![]() |
Date: 2012-06-24 09:52 |
New changeset 4445608cf434 by Larry Hastings in branch 'default': Issue #14815: Bugfix: the PyLong fed into the seed generator must be unsigned. http://hg.python.org/cpython/rev/4445608cf434 |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:57:30 | admin | set | github: 59020 |
2012-06-24 09:52:32 | python-dev | set | messages: + |
2012-06-24 08:56:13 | larry | set | status: open -> closedresolution: fixedtype: enhancementstage: commit review |
2012-06-24 08:54:43 | python-dev | set | nosy: + python-devmessages: + |
2012-06-24 06:56:02 | loewis | set | messages: + |
2012-06-24 06:01:41 | larry | set | files: + larry.random_seed.ssize_t.1.diffkeywords: + patchmessages: + |
2012-06-17 00:56:34 | larry | set | nosy: + larry |
2012-06-16 22:53:45 | rhettinger | set | assignee: rhettinger -> loewis |
2012-06-16 21:24:57 | serhiy.storchaka | set | nosy: + serhiy.storchaka |
2012-05-17 16:28:49 | rhettinger | set | assignee: rhettinger |
2012-05-16 16:33:14 | rhettinger | set | messages: + |
2012-05-15 12:27:41 | pitrou | set | nosy: + rhettinger |
2012-05-15 12:23:02 | loewis | create |