In Python, how can you load YAML mappings as OrderedDicts?
I'd like to get PyYAML 's loader to load mappings (and ordered mappings) into the Python 2.7+ OrderedDict type, instead of the vanilla dict and the list of pairs it currently uses. What's the best way to do that? Update: In python 3.6+ you probably don't need OrderedDict at all due to the new dict implementation that has been in use in pypy for some time (although considered CPython implementation detail for now). Update: In python 3.7+, the insertion-order preservation nature of dict objects has been declared to be an official part of the Python language spec , see What's New In Python 3.7 .