Message309957
random.seed(str) uses:
if version == 2 and isinstance(a, (str, bytes, bytearray)):
if isinstance(a, str):
a = a.encode()
a += _sha512(a).digest()
a = int.from_bytes(a, 'big')
Whereas for other types, random.seed(obj) uses hash(obj), and hash is randomized by default in Python 3.
Yeah, the random.seed() documentation should describe the implementation and explain that hash(obj) is used and that the hash function is randomized by default:
https://docs.python.org/dev/library/random.html#random.seed |
|
Date |
User |
Action |
Args |
2018-01-15 09:13:25 | vstinner | set | recipients:
+ vstinner, rhettinger, mark.dickinson, docs@python, johnnyd |
2018-01-15 09:13:25 | vstinner | set | messageid: <1516007605.67.0.467229070634.issue32554@psf.upfronthosting.co.za> |
2018-01-15 09:13:25 | vstinner | link | issue32554 messages |
2018-01-15 09:13:25 | vstinner | create | |
|