Random alphanumeric string

Siarhei Siamashka siarhei.siamashka at gmail.com
Tue Jan 31 12:33:01 UTC 2023


On Tuesday, 31 January 2023 at 06:29:24 UTC, Cym13 wrote:
> Phobos' is good for statistical analysis and things like 
> choosing a random name
> within a list for a character. It produces numbers that show no 
> clear pattern
> and are spread accross a given probability distribution. Very 
> good for statistics.

It's good for statistics only if we ignore performance, which is 
actually horribly bad in `std.random`. Things like random array 
shuffling are several times slower than they could have been. 
Some of the Phobos problems are listed at 
https://github.com/libmir/mir-random#comparison-with-phobos

What would be a realistic plan to improve `std.random` in Phobos? 
Or is it a better idea to rely on third-party libraries for this 
functionality?

One of the actual use cases of std.random is producing 
deterministic randomish looking sequences for unit tests via a 
deterministic seed. If bounded integers generation in 
`std.random.uniform` is optimized, then these sequences will 
change. Also the default generator is 32-bit Mersenne Twister, 
which is bad for 64-bit systems because generating a random 
size_t index is done via producing two 32-bit numbers and gluing 
them together. But changing the default generator to something 
else will may break some applications.


More information about the Digitalmars-d mailing list