cool-easter-32542
11/21/2023, 4:31 AMFrozenDict type is order sensitive, which differs to a normal dict. It also gives False when comparing to a normal dict. This makes it easy to get unexpected behaviour, and likely leads to unnecessary cache misses.
pants/src/python/pants/util/frozendict.py
Lines 15 to 21 in </pantsbuild/pants/commit/57d1801c80f8273ca386fba198495a05a45f60ae|57d1801>
d1 = {'a': 0, 'b': 1}
d2 = {'b': 1, 'a': 0}
print(d1 == d2) # True
print(FrozenDict(d1) == FrozenDict(d2)) # False
print(FrozenDict(d1) == d1) # False
NB. this seems to apply to all methods that call tuple(self.items()) or similar: __eq__, __lt__, `_calculate_hash`/`__hash__`.
Pants version
main
OS
N/A
Additional info
This caused half of #20210, see #20220.
pantsbuild/pantscool-easter-32542
11/30/2023, 9:58 PM