Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51242
| Date | 2013-07-25 09:21 -0700 |
|---|---|
| From | Ethan Furman <ethan@stoneleaf.us> |
| Subject | Re: Python 3: dict & dict.keys() |
| References | (3 earlier) <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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5110.1374769265.3114.python-list@python.org> (permalink) |
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
Re: Python 3: dict & dict.keys() Ethan Furman <ethan@stoneleaf.us> - 2013-07-25 09:21 -0700
csiph-web