This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ethan.furman
Recipients arigo, ethan.furman, nikratio, rhettinger
Date 2013-10-30.18:56:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1383159366.43.0.0297034703791.issue19414@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-10-30 18:56:06ethan.furmansetrecipients: + ethan.furman, arigo, rhettinger, nikratio
2013-10-30 18:56:06ethan.furmansetmessageid: <1383159366.43.0.0297034703791.issue19414@psf.upfronthosting.co.za>
2013-10-30 18:56:06ethan.furmanlinkissue19414 messages
2013-10-30 18:56:06ethan.furmancreate