| ▲ | FreakLegion 4 days ago | |||||||
> I've felt like frozendict was missing for a long time, though. Type the dict as a mapping when you want immutability:
The only problem I've seen with this is:
The issue here is less that dict isn't hashable than that Mapping is, though. | ||||||||
| ▲ | zahlman 3 days ago | parent [-] | |||||||
This is because the ABC system is defined such that MutableMapping is a subtype of Mapping. Which mostly makes sense, except that if we suppose there exist Mappings that aren't MutableMappings (such that it makes sense to recognize two separate concepts in the first place), then Mapping should be hashable, because immutable things generally should be hashable. Conceptually, making something mutable adds a bunch of mutation methods, but it also ought to take away hashing. So Liskov frowns regardless. | ||||||||
| ||||||||