News for hackers. Stuff that matters.
Re:Python: The Dictionary Playbook by andreasvc on Wednesday January 02, 2013 @07:29PM (#5000318)
Or dictionary views: they stay current as the dictionary is updated, and allow set operations.
Re:Python: The Dictionary Playbook by dougws on Wednesday January 02, 2013 @11:15PM (#5000987)
Have used all of the techniques in the article (plus dict/set comprehensions) but had never heard of dict views [1] until now. Good stuff!

[1] http://docs.python.org/2/library/stdtypes.html#dictionary-vi...

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?
Re:Python: The Dictionary Playbook by e12e on Thursday January 03, 2013 @01:27AM (#5001262)
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:

http://www.python.org/dev/peps/pep-3106/

Re:Python: The Dictionary Playbook by andreasvc on Thursday January 03, 2013 @02:47AM (#5001393)
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.