Delaney, Timothy (Tim) wrote: > This whole discussion suggests to me that what would be best is if we > defined an actual "view" protocol, and various builtins return views, > rather than either copies or iterators.
I'm not sure that any formal protocol is needed. Each container will be providing its own set of methods for producing views, and each of the views will behave in ways specific to the type that it's viewing. I can't see there being a place for anything like the __iter__ slot for views. Each case will be unique. > A view provides the same access methods, etc as the object it is backed > by. They can't be *exactly* the same, or there would be no point in having a view in the first place. > The aim of a view is to be lightweight. Agreed. > A view should not allow modification of the underlying object I think I agree with that, at least in the cases where we're changing an existing method (e.g. dict.keys()) that used to return an independent object. Then code which is expecting the old semantics will fail fairly obviously. Greg _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com