[Python-Dev] Retrieve an arbitrary element from a set withoutremoving it (original) (raw)

Nick 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