News for hackers. Stuff that matters.
Re:StrictYAML by loloquwowndueo on Friday March 07, 2025 @08:15AM (#43289899)
That’s relatively new (introduced in Python 3.6). You wouldn’t believe how many production code bases are still in 3.5 or lower.

The change log for 3.6 states:

The order-preserving aspect of this new implementation is considered an implementation detail and should not be relied upon (this may change in the future, but it is desired to have this new dict implementation in the language for a few releases before changing the language spec to mandate order-preserving semantics for all current and future Python implementations; this also helps preserve backwards-compatibility with older versions of the language where random iteration order is still in effect, e.g. Python 3.5

Therefore it’s advisable to use OrderedDict if there’s even a chance this code might be used with older versions.

Re:StrictYAML by whalesalad on Friday March 07, 2025 @08:51AM (#43290139)
Yeah I recently learned about this after giving another engineer PR feedback that dicts are not ordered and we cannot expect the intended behavior. Jokes on me. Old habits die hard