4 ms·
You're looking for something similar to Python's namedtuple.[1] (Though modern python should use a dataclasses in the stdlib or the attrs package.) Essentially
by ben509 6y ago
You're looking for something similar to Python's namedtuple.[1] (Though modern python should use a dataclasses in the stdlib or the attrs package.)
Essentially, you have an array/list/vector under the hood, and a mapping of field names to array indices to govern field access.
If you're trying to implement this at a lower level, in the interpreted language itself, take a look at the slots mechanism[2] in Python.
[1]: https://docs.python.org/3/library/collections.html#collections.namedtuple https://docs.python.org/3/library/collections.html#collectio...
[2]: https://docs.python.org/3/reference/datamodel.html#object.__slots__ https://docs.python.org/3/reference/datamodel.html#object.__...
- daneelsan 6y agoThat seems like the thing I'm looking for! Thanks for the info