Guido van Rossum wrote: > On 3/23/06, Brett Cannon <[EMAIL PROTECTED]> wrote: >> But I think if objects returned iterators instead of lists the >> iterator-as-view will begin to be used more than viewing them as >> iterator-has-own-data. But this also means that making a more >> view-like interface would be handy. In terms of what would need to be >> supported (len, deletion, etc.) I don't know. I personally have not >> had that much of a need since I then just pass the originating object >> and get the iterator as needed instead of passing around the iterator. > > I'm dead set against giving iterators more view-like properties; it > would rule out generators and other potentially infinite sequences. > > But I'm all for a different concept, views in the sense of Java's > collection framework. Please study it; it's worth it: > > http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collection.html
A very interesting read indeed (Their explanation in the Design FAQ regarding the use of 'UnsupportedOperationException' sounds downright Pythonic. . .) Some more specific reading material can be found by looking at List.subList [1] along with Map.keySet, Map.entrySet and Map.values [2]. An interesting point is that making the views immutable doesn't really make life any easier, because you need to define what happens to the views if someone mutates the *original*. And once you do that, then that means you should be able to define what happens to the original if someone mutates the view. I would be a big fan of adding views as a core concept - it would also provide a nice bridge to the way array slicing works in numpy (you get a mutable view rather than a copy). Regards, Nick. [1] http://java.sun.com/j2se/1.4.2/docs/api/java/util/List.html#subList(int,%20int) [2] http://java.sun.com/j2se/1.4.2/docs/api/java/util/Map.html#keySet() -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org _______________________________________________ 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