Python 3.0 - dict methods return views - why?
问题 dict methods dict.keys(), dict.items() and dict.values() return “views” instead of lists. http://docs.python.org/dev/3.0/whatsnew//3.0.html First of all how is a view different from an iterator? Secondly, what is the benefit of this change? Is it just for performance reasons? It doesn't seem intuitive to me, i.e., I'm asking for a list of thing (give me all your keys) and I'm getting something else back. Will this confuse people? 回答1: You are effectively getting a list. It's just not a copy