Ethan Furman added the comment: Firstly, you're not copying the entire dict, just its keys. [1]
Secondly, you're only copying the keys when you'll be adding/deleting keys from the dict. Thirdly, using the list idiom means you can use OrderedDicts, defaultdicts, dicts, sets, and most likely any other mapping type the same way, whereas if you make OrderedDict special in this area you've locked out the other types. In my opinion the differences in OrderedDict should be limited to what is necessary to make a dict ordered. The ability to insert/delete keys while iterating is not necessary to maintaining an order, and the break from other dicts doesn't add enough value to make it worth it. So, yes, the short answer is because Python's other similar types don't do it that way, OrderedDict shouldn't either. [1] If the dict is large, collect the to_be_deleted keys in a separate list and remove them after the loop. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19414> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com