Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'anyway.': 0.05; 'argument': 0.05; 'subject:Python': 0.06; 'apis': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'skip:/ 10': 0.09; 'subject:()': 0.09; 'wrapped': 0.09; 'api': 0.11; 'python': 0.11; 'api,': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'iterated': 0.16; 'previously,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'rewritten': 0.16; 'set,': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'stefan': 0.19; 'written': 0.21; 'header:User-Agent:1': 0.23; 'library,': 0.24; "shouldn't": 0.24; 'fairly': 0.24; 'looks': 0.24; '(or': 0.24; 'question': 0.24; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'specifically': 0.29; 'gives': 0.31; 'code': 0.31; 'could': 0.34; 'problem.': 0.35; 'received:84': 0.35; 'there': 0.35; 'opposed': 0.36; 'method': 0.36; 'so,': 0.37; 'two': 0.37; 'list': 0.37; 'being': 0.38; 'needed': 0.38; 'to:addr:python-list': 0.38; 'little': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:org': 0.40; 'how': 0.40; 'even': 0.60; 'consists': 0.60; 'most': 0.60; 'identify': 0.61; 'new': 0.61; 'simply': 0.61; 'more': 0.64; 'different': 0.65; 'subject: & ': 0.68; 'special': 0.74; 'adapted': 0.84; 'ages': 0.84; 'ethan': 0.84; 'everything.': 0.84; 'furman': 0.84; 'received:arcor-ip.net': 0.84; 'received:pools.arcor-ip.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Stefan Behnel Subject: Re: Python 3: dict & dict.keys() Date: Wed, 24 Jul 2013 19:23:47 +0200 References: <51EF2AD8.3080105@stoneleaf.us> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: dslb-084-056-000-054.pools.arcor-ip.net User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1374686640 news.xs4all.nl 15922 [2001:888:2000:d::a6]:44841 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51153 Peter Otten, 24.07.2013 08:23: > Ethan Furman wrote: >> So, my question boils down to: in Python 3 how is dict.keys() different >> from dict? What are the use cases? > > I just grepped through /usr/lib/python3, and could not identify a single > line where some_object.keys() wasn't either wrapped in a list (or set, > sorted, max) call, or iterated over. In case that directory mainly consists of the standard library, then you shouldn't forget that most of the code in there predates Python 3 by ages and was only adapted to work with the new syntax/semantics, not rewritten in a "better" way. Even if it's not just the stdlib, that argument still holds. There is still fairly little code out there that was specifically written for Py2.6+, as opposed to just being adapted. > To me it looks like views are a solution waiting for a problem. They reduce the API overhead. Previously, you needed values() and itervalues(), with values() being not more than a special case of what itervalues() provides anyway. Now it's just one method that gives you everything. It simply has corrected the tradeoff from two special purpose APIs to one general purpose API, that's all. Stefan