Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

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

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Apr 30, 2012, 7:32 AM

Post #1 of 2 (70 views)
Permalink
[issue7522] random.choice should accept a set as input

Michele Mazzucchi <michele [at] buddyns> 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 [at] bugs>
<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


report at bugs

Apr 30, 2012, 11:25 AM

Post #2 of 2 (61 views)
Permalink
[issue7522] random.choice should accept a set as input [In reply to]

Mark Dickinson <dickinsm [at] gmail> 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 [at] bugs>
<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

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.