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


Groups > comp.lang.python > #51252

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

From Terry Reedy <tjreedy@udel.edu>
Subject Re: Python 3: dict & dict.keys()
Date 2013-07-25 14:37 -0400
References (4 earlier) <kspbms$atn$1@ger.gmane.org> <5B80DD153D7D744689F57F4FB69AF474185C131B@SCACMX008.exchad.jpmchase.net> <kspouu$sh8$1@ger.gmane.org> <5B80DD153D7D744689F57F4FB69AF474185CA82D@SCACMX008.exchad.jpmchase.net> <51F1506E.2020800@stoneleaf.us>
Newsgroups comp.lang.python
Message-ID <mailman.5114.1374777455.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 7/25/2013 12:21 PM, Ethan Furman wrote:
> On 07/25/2013 09:11 AM, Prasad, Ramit wrote:

>> 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.

I think 'view' is generally used in CS to mean a live view, as opposed 
to a snapshot. Memoryviews in 3.x are also live views. Dictionary views 
are read-only. I believe memoryviews can be read-write if allowed by the 
object being viewed.

Python slices are snapshots. It has been proposed that they should be 
views to avoid copying memory, but that has been rejected since views 
necessarily keep the underlying object alive. Instead, applications can 
define the views they need. (They might, for instance, allow multiple 
slices in a view, as tk Text widgets do.)

-- 
Terry Jan Reedy

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


Thread

Re: Python 3: dict & dict.keys() Terry Reedy <tjreedy@udel.edu> - 2013-07-25 14:37 -0400

csiph-web