The same as it is right now (i.e. IIRC people are still arguing), given that tomllib is currently implementing TOML 1.0.0 (as stated on top of tomllib doc).
Sure. However, this is not stated explicitly (and to be honest, the TOML spec is not exactly 100% precise there either), so there is space to mistakes. Especially given that the order-preserving behavior is something ubiquitous to Python.
Funny you should mention that, given that I’m asking this question precisely because uv is using a TOML file where dictionary key order is significant, so the answer here pretty much determines whether we can use tomllib to parse this file, or if we need to implement a separate “extended” TOML parser that supports this feature.
Looking at the relevant issue (Document order-preserving dictionary output in json), looks like people actually found the behavior helpful.
Depends on the format. Sometimes an ordered dictionary is the simplest and least confusing thing you can give to a user. Compare, say:
[ordered-thing]
first = "..."
second = "..."
vs.
[[ordered-thing]]
key = "first"
value = "..."
[[ordered-thing]]
key = "second"
value = "..."
Yes, the second form is 100% TOML-compliant but it’s a lot more typing for a human to do, and I dare say it’s less readable. And I really can’t think of a much better alternative.
I disagree here. We are explicitly recommending tomli-w to be paired with tomllib, at the very top of the tomllib documentation.