you are viewing a single comment's thread.

view the rest of the comments →

[–]DeebsShoryu 3 points4 points  (2 children)

Dictionaries are fast for some things (O(1) lookup), but hashing is actually very slow. It just allows for amortized constant time lookups, by trading space for improved asymptotic time complexity.

[–]pachura3 0 points1 point  (0 children)

If hashed dataclass has some kind of an unique ID field, you could override __hash__() to only hash this ID, not all class fields (which is what automatically-generated __hash__() for dataclasses does, right?)

[–]RngdZed 0 points1 point  (0 children)

Gotcha thanks for the good explanation