[issue31992] Make iteration over dict_items yield namedtuples

2017-11-10 Thread R. David Murray
R. David Murray added the comment: This is not something it is worth complicating the dict API or collections for. If you want the feature in your code, implement your subclass in your own utility library. If you disagree with this decision, please bring it up on the python-ideas mailing li

[issue31992] Make iteration over dict_items yield namedtuples

2017-11-10 Thread Richard Neumann
Richard Neumann added the comment: Maybe there is no need to sacrifice performance, if a new, optional keyword argument would be introduced to dict.items(): def items(self, named=False): if named: else: Currently I need to define a namedtuple ever

[issue31992] Make iteration over dict_items yield namedtuples

2017-11-09 Thread Eric V. Smith
Eric V. Smith added the comment: I cannot imagine this ever happening, for performance reasons. You should write your own wrapper around items, if you want this behavior. -- nosy: +eric.smith ___ Python tracker

[issue31992] Make iteration over dict_items yield namedtuples

2017-11-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Oh, no! Tuples is one of the most charming features of Python. Use tuples, folk! -- nosy: +rhettinger, serhiy.storchaka ___ Python tracker _

[issue31992] Make iteration over dict_items yield namedtuples

2017-11-09 Thread Richard Neumann
New submission from Richard Neumann : Currently, iterating over dict_items will yield plain tuples, where the first item will be the key and the second item will be the respective value. This has some disadvantages when e.g. sorting dict items by value and key: def sort_by_value_len(dictio