A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2009-October/093421.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 itNick Coghlan ncoghlan at gmail.com
Wed Oct 28 07:40:08 CET 2009
Guido van Rossum wrote:
> My gut tells me it is bad API design to collapse these two use cases.
> Probably because the implementations won't have much in common: (1)
> should just pick the first valid element, while (2) should use the
> normal hash lookup algorithm (shared with 'in', .add() etc.).

As a side note, a fairly obvious method name for "add if missing and
then return canonical representation" did occur to me: s.intern(x)

I'd be -0 on expanding the set API for this though (since the cookbook
recipe overloading __eq__ already provides an efficient solution).

As far as the moratorium in general goes, perhaps we should draw a line
between API changes that affect the ABCs in collections and numbers and
new convenience methods on the builtin types themselves?

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
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