Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #51242

Re: Python 3: dict & dict.keys()

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ethan@stoneleaf.us>
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; 'subject:Python': 0.06; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:184.172': 0.09; 'received:gator410.hostgator.com': 0.09; 'subject:()': 0.09; '~ethan~': 0.09; 'assume': 0.14; 'changes': 0.15; 'hashed': 0.16; 'iterables': 0.16; 'iterated': 0.16; 'keys.': 0.16; 'nope,': 0.16; 'once.': 0.16; 'reedy': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'equivalent': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'array': 0.29; 'operations.': 0.31; 'updated': 0.34; 'sense': 0.34; 'possible.': 0.35; 'operations': 0.35; 'functions.': 0.36; 'charset:us-ascii': 0.36; 'clear': 0.37; 'implement': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'easy': 0.60; 'new': 0.61; 'received:173': 0.61; 'show': 0.63; 'therefore,': 0.64; 'more': 0.64; 'subject: & ': 0.68; 'lists:': 0.91
Date Thu, 25 Jul 2013 09:21:02 -0700
From Ethan Furman <ethan@stoneleaf.us>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1
MIME-Version 1.0
To python-list@python.org
Subject Re: Python 3: dict & dict.keys()
References <51EF2AD8.3080105@stoneleaf.us> <ksnrr9$k4t$1@ger.gmane.org> <ksp2it$21p$1@ger.gmane.org> <51F01D9E.2030903@stoneleaf.us> <kspbms$atn$1@ger.gmane.org> <5B80DD153D7D744689F57F4FB69AF474185C131B@SCACMX008.exchad.jpmchase.net> <kspouu$sh8$1@ger.gmane.org> <5B80DD153D7D744689F57F4FB69AF474185CA82D@SCACMX008.exchad.jpmchase.net>
In-Reply-To <5B80DD153D7D744689F57F4FB69AF474185CA82D@SCACMX008.exchad.jpmchase.net>
Content-Type text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding 7bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - gator410.hostgator.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - stoneleaf.us
X-BWhitelist no
X-Source
X-Source-Args
X-Source-Dir
X-Source-Sender ([173.12.184.233]) [173.12.184.233]:52164
X-Source-Auth ethan+stoneleaf.us
X-Email-Count 1
X-Source-Cap dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ==
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5110.1374769265.3114.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1374769265 news.xs4all.nl 15994 [2001:888:2000:d::a6]:48904
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:51242

Show key headers only | View raw


On 07/25/2013 09:11 AM, Prasad, Ramit wrote:
> Terry Reedy wrote:
>>
>> On 7/24/2013 4:34 PM, Prasad, Ramit wrote:
>>
>>> I am still not clear on the advantage of views vs. iterators.
>>
>> A1: Views are iterables that can be iterated more than once. Therefore,
>> they can be passed to a function that re-iterates its inputs, or to
>> multiple functions. They support 'x in view' as efficiently as possible.
>> Think about how you would write the non-view equivalent of '(0,None) in
>> somedict.views())'. When set-like, views support some set operations.
>> For .keys, which are always set-like, these operations are easy to
>> implement as dicts are based on a hashed array of keys.
>
> Hmm, that is a change that makes some sense to me. Does the view
> get updated when dictionary changes or is a new view needed? I
> assume the latter.

Nope, the former.  That is a big advantage that the views have over concrete lists: they show the /current/ state, and 
so are always up-do-date.

--
~Ethan~

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Python 3: dict & dict.keys() Ethan Furman <ethan@stoneleaf.us> - 2013-07-25 09:21 -0700

csiph-web