[issue7522] random.choice should accept a set as input

Mark Dickinson report at bugs.python.org
Thu May 6 13:40:41 CEST 2010


Mark Dickinson <dickinsm at gmail.com> added the comment:

> As far as I know, it is a binary search tree,

It's not:  it's based on a hash table.  It's essentially a dict with keys but no values.  An additional complication is that the hash table can be very sparsely filled, in the case of a large set that has had most of its elements deleted---there's no automatic shrinkage of the hash table in that case.  So repeated random selection until you find a filled hash table entry would be inefficient in that case.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7522>
_______________________________________


More information about the Python-bugs-list mailing list