> > Pronouncement: > > > > It is only efficient to get the *first* item, so let's make that > > explicit. The method names will be: > > > > .firstkey() > > -1 > > > .firstvalue() > > -1 > > > .firstitem() > > +1 > > I really think that .firstitem() is both more intuitive and > efficient -- .firstvalue() and .firstkey() are simply derivatives > of this method or how would you define the return value of > those two methods ? Yes, firstvalue() and firstkey() return just the value or just the key. I can see that the first value is not very useful (since you don't have the key, you can't mutate the dict). firstkey() might be just the ticket e.g. for set implementations. OTOH you may be right that it's best to add the minimal number of new methods. > > Moshe will check in a patch. > > > > Thinking aloud: > > > > Would it be useful to also implement popkey(), popvalue(), popitem(), > > which would remove the first item and then return the relevant part of > > it? > > +1 > > Same comment as above... .popitem() suffices. And for minimality reasons I'm at most -0 on it. --Guido van Rossum (home page: http://www.python.org/~guido/)
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