←back to thread

191 points jwilk | 1 comments | | HN request time: 0.198s | source
1. lou1306 ◴[] No.46231130[source]
Can someone give a strong rationale for a separate built-in class? Because "it prevents any unintended modifications" is a bit weak.

If you have fixed keys, a frozen dataclass will do. If you don't, you can always start with a normal dict d, then store tuple(sorted(d.items())) to have immutability and efficient lookups (binary search), then throw away d.