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.
Created on 2010年10月04日 23:33 by goddard, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (4) | |||
|---|---|---|---|
| msg117988 - (view) | Author: Tom Goddard (goddard) | Date: 2010年10月04日 23:33 | |
In Python 2.7, random.seed() with a string argument is documented as being equivalent to random.seed() with argument equal to the hash of the string argument. This is not the actual behavior. Reading the _random C code reveals it in fact casts the signed hash value to unsigned long. This also appears to be the situation with Python 2.5.2. Rather than fix this in 2.7.1 it seems preferable to just correct the documentation in 2.7.1 to preserve backward compatibility. Bug #7889 has already addressed this problem in Python 3.2 by eliminating the use of hash() for non-integer random.seed() arguments. I encountered this problem while trying to produce identical sequences of random numbers on 64-bit architectures as on 32-bit architectures. Here is a demonstration of the bug in Python 2.7, 32-bit. random.seed('1pov') random.uniform(0,1) 0.713827305919223 random.seed(hash('1pov')) random.uniform(0,1) 0.40934677883730686 hash('1pov') -747753952 random.seed(hash('1pov') + 2**32) # unsigned long cast random.uniform(0,1) 0.713827305919223 |
|||
| msg118233 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2010年10月08日 23:07 | |
3.1 has the same problem (and the same results as above) Assuming behavior is not changed, please suggest a specific rewording that you would be happy with and that is not too verbose. |
|||
| msg118238 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2010年10月09日 00:01 | |
Perhaps replace equivalent with "based on" or some such. This is a very minor nit and likely of interest to no one except the OP. |
|||
| msg120076 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2010年10月31日 18:16 | |
Removed the inaccurate description. See r86053. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:07 | admin | set | github: 54234 |
| 2010年10月31日 18:16:03 | rhettinger | set | status: open -> closed resolution: fixed messages: + msg120076 |
| 2010年10月09日 00:01:31 | rhettinger | set | priority: normal -> low messages: + msg118238 |
| 2010年10月08日 23:07:13 | terry.reedy | set | versions:
+ Python 3.1 nosy: + terry.reedy messages: + msg118233 components: + Documentation stage: needs patch |
| 2010年10月05日 02:32:40 | rhettinger | set | assignee: rhettinger |
| 2010年10月05日 00:01:38 | r.david.murray | set | nosy:
+ rhettinger |
| 2010年10月04日 23:33:05 | goddard | create | |