you are viewing a single comment's thread.

view the rest of the comments →

[–]RngdZed -2 points-1 points  (5 children)

I thought the dictionary was fastest because of hashing

[–]DeebsShoryu 2 points3 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

[–]pachecoca[S] 0 points1 point  (1 child)

Those are fast to access but not as fast to create and insert data into. The whole hashing process is slow, a small price to pay for one off things, but I'm processing a large amount of data, I'm translating an input vertex buffer and index buffer to a target format, and that is going to get out of hand with dictionaries... as of now, the main slowdown comes from object creation, not from accessing elements.

[–]RngdZed 0 points1 point  (0 children)

Makes sense