[issue32554] random seed is not consistent when using tuples with a str element
STINNER Victor <victor.stinner@gmail.com> added the comment: 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 ---------- assignee: -> docs@python components: +Documentation nosy: +docs@python, mark.dickinson, rhettinger, vstinner _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue32554> _______________________________________
participants (1)
-
STINNER Victor