Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When calling
seed!(rng, seed), theseedis converted into random bytes, which are then expanded to produce the initialization state forrng. The purpose of hashing is to ensure thatMyRNG(1)andMyRNG(2)produce uncorrelated streams.In practice, this call is implemented as
seed!(rng, SeedHasher(seed)), assuming thatrngimplementsseed!(::AbstractRNG)for initialization from another RNG.Previously,
SeedHasherworked in three stages:seedinto bytesThis approach was functional but relatively slow.
This commit replaces stages 2 and 3 with an algorithm designed specifically for seed generation by M. E. O'Neill, described at: https://www.pcg-random.org/posts/developing-a-seed_seq-alternative.html
The implementation is adapted from O'Neill's
seed_seq_feC++ reference (MIT license). NumPy uses the same algorithm for itsSeedSequence.Here are some numbers:
On master:
On PR: