A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-November/093682.html below:

[Python-Dev] Retrieve an arbitrary element from a set withoutremoving it

[Python-Dev] Retrieve an arbitrary element from a set withoutremoving it [Python-Dev] Retrieve an arbitrary element from a set withoutremoving itAntoine Pitrou solipsis at pitrou.net
Wed Nov 4 00:21:56 CET 2009
Guido van Rossum <guido <at> python.org> writes:
> 
> You're obviously talking about a *random* element. This is a separate
> use case (though I agree many people don't know the difference).
> 
> Picking a random element can be done in O(1) only if the data
> structure supports access by index, which Python's hash tables don't.

Well, at the implementation level, they can. You'd just have to pick a new
random index until it points to a non-empty slot.

Regards

Antoine.


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4