[Numpy-discussion] reseed random generator (1.19)
Robert Kern
robert.kern at gmail.com
Mon Jun 29 16:05:57 EDT 2020
On Mon, Jun 29, 2020 at 11:30 AM Robert Kern <robert.kern at gmail.com> wrote:
> On Mon, Jun 29, 2020 at 11:10 AM Kevin Sheppard <
> kevin.k.sheppard at gmail.com> wrote:
>
>>
>> 1. The total number of digits in the binary representation is
>> somewhere between 32 and 128.
>>
>>
> I like using the standard library `secrets` module.
>
> >>> import secrets
> >>> secrets.randbelow(1<<128)
> 8080125189471896523368405732926911908
>
> If you want an easy-to-follow rule, just use the above snippet to get a
> 128-bit number. More than 128 bits won't do you any good (at least by
> default, the internal bottleneck inside of SeedSequence is a 128-bit pool),
> and 128-bit numbers are just about small enough to copy-paste comfortably.
>
Sorry, `secrets.randbits(128)` is the cleaner form of this.
--
Robert Kern
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20200629/8a5be4fd/attachment.html>
More information about the NumPy-Discussion
mailing list