Stefan Behnel <stefan...@behnel.de> added the comment:

FWIW, I second Raymond's opposition against a new option. It's really not 
something that users should care about. Instead of us providing a new "sort or 
not" option, and people adding it (conditionally!) to their code to "fix" 
previous or future behaviour of the tool, they should better invest the time 
into fixing their code to not rely on behaviour that was never guaranteed.

Also, lxml cannot support such a serialisation option because it preserves the 
order of attributes as soon as they are *created*. It previously also sorted 
dicts on input, but only dicts and not other (sequential) ways to set 
attributes, which I always considered a necessary quirk to gain reproducible 
output. I'm planning to remove the sorting for Py3.6+ in the next release. It 
is better to leave the decision about attribute order entirely to the users.

It's not difficult to get sorted dict behaviour in Py3.6+ if you really want it 
(walk the tree and sort each el.attrib if you feel like it), but it's currently 
impossible to _not_ get sorted attributes but the "expected" order of creation. 
That's what we should fix.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34160>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to