In general I think that the current method iterates over the KeySet for finding a random value, while I think that the new one requires almost just a constant cost
Specifically, what needs to be done here is to add few lines around Random/src/generation.jl:440 to add sampling for KeySet (and potentially ValueIterator)
Consider this simple benchmark
on my computer under 1.9.3, it returns
It sounded a bit slow (and more the number of elements gets bigger more it is so) then I tried
which gave me
Can't something similar be used instead?
In general I think that the current method iterates over the
KeySet
for finding a random value, while I think that the new one requires almost just a constant cost