[Python-ideas] random.choice on non-sequence
Chris Angelico
rosuav at gmail.com
Tue Apr 12 22:15:28 EDT 2016
On Wed, Apr 13, 2016 at 12:11 PM, Guido van Rossum <guido at python.org> wrote:
> This is no good. Who wants a choice() that is O(1) on sequences but
> degrades to O(N) if the argument is a set?
Fair point. Suggestion withdrawn.
If you want something that does the iteration-till-it-finds-something,
that should be a separate function. (And then it'd work automatically
on dicts, too.)
ChrisA
More information about the Python-ideas
mailing list