{"action":"created","issue":{"url":"https://api.github.com/repos/yaml/pyyaml/issues/110","repository_url":"https://api.github.com/repos/yaml/pyyaml","labels_url":"https://api.github.com/repos/yaml/pyyaml/issues/110/labels{/name}","comments_url":"https://api.github.com/repos/yaml/pyyaml/issues/110/comments","events_url":"https://api.github.com/repos/yaml/pyyaml/issues/110/events","html_url":"https://github.com/yaml/pyyaml/issues/110","id":281298648,"number":110,"title":"order in dict is not preserved","user":{"login":"MazokuMaxy","id":30230821,"avatar_url":"https://avatars0.githubusercontent.com/u/30230821?v=4","gravatar_id":"","url":"https://api.github.com/users/MazokuMaxy","html_url":"https://github.com/MazokuMaxy","followers_url":"https://api.github.com/users/MazokuMaxy/followers","following_url":"https://api.github.com/users/MazokuMaxy/following{/other_user}","gists_url":"https://api.github.com/users/MazokuMaxy/gists{/gist_id}","starred_url":"https://api.github.com/users/MazokuMaxy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MazokuMaxy/subscriptions","organizations_url":"https://api.github.com/users/MazokuMaxy/orgs","repos_url":"https://api.github.com/users/MazokuMaxy/repos","events_url":"https://api.github.com/users/MazokuMaxy/events{/privacy}","received_events_url":"https://api.github.com/users/MazokuMaxy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2017-12-12T08:34:47Z","updated_at":"2018-05-27T12:33:11Z","closed_at":null,"author_association":"NONE","body":"Python 3.6.3\r\n`import yaml`\r\n`document = \"\"\"`\r\n`  b:`\r\n`    c: 3`\r\n`    d: 4`\r\n`  a: 1`\r\n`\"\"\"`\r\n`print(yaml.dump(yaml.load(document), default_flow_style=False))`\r\n`a: 1`\r\n`b:`\r\n`  c: 3`\r\n`  d: 4`\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/yaml/pyyaml/issues/comments/392327781","html_url":"https://github.com/yaml/pyyaml/issues/110#issuecomment-392327781","issue_url":"https://api.github.com/repos/yaml/pyyaml/issues/110","id":392327781,"user":{"login":"mayou36","id":17454848,"avatar_url":"https://avatars3.githubusercontent.com/u/17454848?v=4","gravatar_id":"","url":"https://api.github.com/users/mayou36","html_url":"https://github.com/mayou36","followers_url":"https://api.github.com/users/mayou36/followers","following_url":"https://api.github.com/users/mayou36/following{/other_user}","gists_url":"https://api.github.com/users/mayou36/gists{/gist_id}","starred_url":"https://api.github.com/users/mayou36/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mayou36/subscriptions","organizations_url":"https://api.github.com/users/mayou36/orgs","repos_url":"https://api.github.com/users/mayou36/repos","events_url":"https://api.github.com/users/mayou36/events{/privacy}","received_events_url":"https://api.github.com/users/mayou36/received_events","type":"User","site_admin":false},"created_at":"2018-05-27T12:33:11Z","updated_at":"2018-05-27T12:33:11Z","author_association":"NONE","body":"@shoogle you are right, I've formulated things wrong: **guaranteeing** an order does not break the yaml specs of course, but _extend_ them. And while there is definitely more use in returning insertion-ordered dicts, the question is whether this should be *guaranteed* inside the basic converter PyYAML or be \"sold as an extension in an extension\".\r\n\r\nI think the question really boils down to the \"problem\" of backwards compatibility: I could not find it, but does PyYAML guarantee somewhere, that the dumping will be sorted?\r\n\r\nOtherwise: Python never guaranteed an order/sorting of the dicts (up to 3.7) and neither does yaml (or PyYAML, if the sorting was not a guaranteed feature). So no one actually could have relied on any kind of sorting.\r\n\r\nI guess: who really relied on the insertion-order used `OrderedDict` together with one of the extensions that *explicitly* deal with this *problem* (like [yamlloader](https://github.com/Phynix/yamlloader) which try to keep up their compatibility (but that's a different use case). If, as a user, you are concerned about backwards compatibility now (say you write 3.7, use the dict and rely on it's order), you anyway have to use OrderedDict *if* you concern about backwards compatibility (and therefore again maybe still rely on extensions).\r\n\r\nSo: yes, extend the yaml specs in order to stick closely to the python specs and guarantee the insertion-order behavior in PyYAML for 3.7+ "}}
{"actor":{"display_login":"mayou36"}}