3 ms·
Couldn't you just do the following? from random import choice choice(list(myset)) (I'm guessing you'd want to do it without having to convert it to a list
by silvertab 16y ago
Couldn't you just do the following?
from random import choice
choice(list(myset))
(I'm guessing you'd want to do it without having to convert it to a list first?)
- pjscott 16y agoThat's what I ended up doing, but this was happening with a very large set, right in an inner loop. Luckily this was running in batch mode, so I could go get lunch or something instead of taking the time to make it faster.