rcl icon indicating copy to clipboard operation
rcl copied to clipboard

Don't alphabetize dict keys

Open topher96 opened this issue 1 month ago • 1 comments

I find it surprising that it alphabetizes keys in dicts rather than using the order I use internally. As an example from another oss project - Python has treated dicts as ordered for a while.

topher96 avatar Nov 27 '25 08:11 topher96

I agree, this is a behavior that I want to change in the future to preserve insertion order, and there are to dos for it in the code and in the documentation.

There are downsides to it too (it breaks the property that a == b ⇒ f(a) == f(b)), but right now now I’m leaning towards that preserving insertion order is a more useful property than this particular form of referential transparency.

The current behavior is an artifact of dicts being implemented with a BTreeMap.

ruuda avatar Nov 27 '25 17:11 ruuda