3 ms·
It depends on what you want its footprint in memory to look like. Since you don't need to mutate the structure, a densely packed structure seems optimal. For sm
by sgtnoodle 6y ago
It depends on what you want its footprint in memory to look like. Since you don't need to mutate the structure, a densely packed structure seems optimal. For small structures, linearly searching through an array would be fast. For larger structures, a sorted array could be binary searched efficiently.
It also depends on how you can represent the string and their typical size. If the strings are small, then allocating fixed size chunks to store them inline might make sense. If the strings are long, it might make sense to go crazy and use a "trie" data structure to minimize comparisons.
I believe python uses hash maps for classes by default, but you can alternatively use "slots", which are less mutable and presumably more densely packed.
- daneelsan 6y agoYes. At some point i encountered this trie with payloads (which would act as t he field values).