STINNER Victor <[email protected]> added the comment:
The performance of the new method is not my first motivation.
My first motivation is to avoid consumers of the random to write a wrong
implementation which would be biased. It's too easy to write biased functions
without notifying.
Moreover, it seems like we can do something to get reproducible behavior on
different architectures (different endianness) which would also be a nice
feature.
For example, in bpo-13396, Amaury found this two functions in the wild:
* struct.pack("Q", random.getrandbits(64))
* sha1(str(random.getrandbits(8*20))).digest()
As I wrote, users are creative to workaround missing features :-) I don't think
that these two implementations give the same result on big and little endian.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue40286>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com