Mailing List Archive

[issue7522] random.choice should accept a set as input
Michele Mazzucchi <michele@buddyns.com> added the comment:

Folks, I really think this should be addressed.

Python has beautiful data structure semantics, and this is a stain in them.

An implementation based on the current underlying hash table is quite simple, just pick random addresses until an active key is found. Even on sparse tables this is probabilistic O(1). Even with average load factor = 50%, only 1 extra attempt is needed; 2 with LF as low as 33%.

I'm happy to provide a patch if anyone defines the desired API in Include/setobject.h .

----------
nosy: +michelem

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue7522>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue7522] random.choice should accept a set as input [ In reply to ]
Mark Dickinson <dickinsm@gmail.com> added the comment:

Michele, you might want to raise this on the python-dev or python-ideas mailing list---it'll get better exposure there than in this closed issue.

For completeness, see also the previous discussion in issue 936988.

----------

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue7522>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com