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

Create rand function for Base.KeySet and Base.ValueIterator{Dict} #51608

Merged
merged 5 commits into from
Oct 9, 2023

Conversation

Tortar
Copy link
Contributor

@Tortar Tortar commented Oct 5, 2023

Fixes #51605 .

I also created a version of rand for Base.ValueIterator{Dict} which currently throws an error.

@oscardssmith oscardssmith added the performance Must go faster label Oct 5, 2023
@oscardssmith
Copy link
Member

Does this work as is or do you also need to define the Sampler constructor? (not rhetorical, I actually don't know the answer)

@Tortar
Copy link
Contributor Author

Tortar commented Oct 5, 2023

Tested with Revise before doing the PR to see if benchmark results improved and they did, it should work as it is.

Also I think the constructor is already defined and called here:

rand(rng::AbstractRNG, X) = rand(rng, Sampler(rng, X, Val(1)))

@rfourquet rfourquet added the randomness Random number generation and the Random stdlib label Oct 6, 2023
Copy link
Member

@rfourquet rfourquet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but this would need tests which exercise the new code paths.

stdlib/Random/src/generation.jl Outdated Show resolved Hide resolved
@Tortar
Copy link
Contributor Author

Tortar commented Oct 6, 2023

tests added and locally run 👍

@Tortar Tortar requested a review from rfourquet October 7, 2023 17:27
@rfourquet rfourquet merged commit 4115c72 into JuliaLang:master Oct 9, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster randomness Random number generation and the Random stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Making rand for a Base.KeySet faster
3 participants