What you do to consume only one bit of entropy at a time has been tried on MersenneTwister without success: it generates natively (2 times) 52 bits of entropy at once, very fast, so even simple operations to save individual bits for later are more costly than generating 52 more bits. Note that this is very specific to this particular RNG, and could very well change as soon as we get a new default RNG (which seems to be on its way
). So IIRC, even rand(Bool) just take 1 out of 52 bits and discards the others (in the scalar case, there are other possible optimization when generating random arrays).
So one possible way (if you donβt mind using internals) for your example to try to get slighly faster is to use rand(Random.UInt52Raw()) and consume 52 bits one by one rather than rand(UInt64), as the latter internally consumes actually 104 bits of entropy (2*52) and not 64.