Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let rand::rng() use OsRng unless thread_rng is enabled? #1545

Open
dhardy opened this issue Dec 27, 2024 · 1 comment
Open

Let rand::rng() use OsRng unless thread_rng is enabled? #1545

dhardy opened this issue Dec 27, 2024 · 1 comment
Labels
E-question Participation: opinions wanted

Comments

@dhardy
Copy link
Member

dhardy commented Dec 27, 2024

ThreadRng adds some thread-local memory. In case not all users want this, we could add a thread_rng feature flag (probably default-enabled).

Where the thread_rng feature is not enabled, rand::rngs::ThreadRng would not be available. rand::rng() would instead use OsRng (assuming that getrandom is available), thus thread_rng would mostly be a performance boost (at the cost of extra code and thread-local memory).

@dhardy dhardy added the E-question Participation: opinions wanted label Dec 27, 2024
@newpavlov
Copy link
Member

Personally, I would be somewhat surprised by such behavior, so I lean slightly against it. Though, it's not a strong opinion, so I would be fine with such change.

@dhardy dhardy mentioned this issue Jan 3, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-question Participation: opinions wanted
Projects
None yet
Development

No branches or pull requests

2 participants