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: 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) Date: 2012-06-24 06:01
I got bored so I made you a patch.
msg163737 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2012-06-24 06:56
LGTM
msg163752 - (view) Author: Roundup Robot (python-dev) (Python triager) 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) (Python triager) 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:30adminsetgithub: 59020
2012-06-24 09:52:32python-devsetmessages: + msg163758
2012-06-24 08:56:13larrysetstatus: open -> closed
resolution: fixed
type: enhancement
stage: commit review
2012-06-24 08:54:43python-devsetnosy: + python-dev
messages: + msg163752
2012-06-24 06:56:02loewissetmessages: + msg163737
2012-06-24 06:01:41larrysetfiles: + larry.random_seed.ssize_t.1.diff
keywords: + patch
messages: + msg163719
2012-06-17 00:56:34larrysetnosy: + larry
2012-06-16 22:53:45rhettingersetassignee: rhettinger -> loewis
2012-06-16 21:24:57serhiy.storchakasetnosy: + serhiy.storchaka
2012-05-17 16:28:49rhettingersetassignee: rhettinger
2012-05-16 16:33:14rhettingersetmessages: + msg160880
2012-05-15 12:27:41pitrousetnosy: + rhettinger
2012-05-15 12:23:02loewiscreate