Re:Python: The Dictionary Playbook
by te on Thursday January 03, 2013 @12:28AM
(#5001161)
I don't get it. Why would I use a view instead of the dictionary itself?
[ Parent
| on HN ]
http://stackoverflow.com/questions/340850/python-3-0-dict-me...
Views are lighter than a full copy of a list, yet behaves like a list (eg: supports `key in view`).
[edit] Also, this seems to be the relevant PEP:
It's not meant as a replacement; views form the new implementation of the keys(), values(), and items() methods in Python 3. The have been made available in Python 2 as viewkeys() etc. As said, they have the advantage of providing set operations (e.g., intersection with the keys of another dictionary), and they are more efficient than keys() or iterkeys(), because they have less overhead.