You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's lots of things that currently exist as lists in the codebase (e.g. lists of order ids, lists of tracking #s, lists of entire cluster objects, etc.). These should be converted into OrderedDicts for reasons of code cleanliness and efficiency, especially in cases where there is a unique key (e.g. the map of tracking #s to order #s). It gets a little bit harder for the clusters list, because there's no obvious unique key there since each cluster can have N trackings and N orderings. If we keyed it off the tracking and then put the same object as the value for every tracking key, it's not clear to me that, after a pickle serialization/deserialization round trip, they'd still be the same objects!
As for why OrderedDict over just plain dict, OrderedDict preserves insertion order, which is what we want. Thus the older order IDs and tracking #s would continue to remain at the front of the respective lists, exactly like how ImmutableSet and ImmutableMap in Guava preserve insertion order. Unfortunately it doesn't appear that Python has a simple set that preserves insertion order (at least not in the stdlib), but OrderedDict probably suffices in most casts.
The text was updated successfully, but these errors were encountered:
There's lots of things that currently exist as lists in the codebase (e.g. lists of order ids, lists of tracking #s, lists of entire cluster objects, etc.). These should be converted into OrderedDicts for reasons of code cleanliness and efficiency, especially in cases where there is a unique key (e.g. the map of tracking #s to order #s). It gets a little bit harder for the clusters list, because there's no obvious unique key there since each cluster can have N trackings and N orderings. If we keyed it off the tracking and then put the same object as the value for every tracking key, it's not clear to me that, after a pickle serialization/deserialization round trip, they'd still be the same objects!
As for why OrderedDict over just plain dict, OrderedDict preserves insertion order, which is what we want. Thus the older order IDs and tracking #s would continue to remain at the front of the respective lists, exactly like how ImmutableSet and ImmutableMap in Guava preserve insertion order. Unfortunately it doesn't appear that Python has a simple set that preserves insertion order (at least not in the stdlib), but OrderedDict probably suffices in most casts.
The text was updated successfully, but these errors were encountered: