Python 3: dict & dict.keys()

Terry Reedy tjreedy at
Thu Jul 25 20:37:14 CEST 2013

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

More information about the Python-list mailing list