I have a list and in each list element, I need some details.
What will be more efficient to use the list in the list
[[‘brown’, ‘wood’, 2], [‘red’, ‘box’, 3 ],…]
Or create a new class for the parameters(details) of color, type, etc.. and creating objects from this class in every element of the list.
[object1,object2,…]
Or any other solution?
List of lists will be more efficient(as in less overhead for function calls, object creation, object destruction etc and take up less space in memory), however creating a new class might be better for readability, writability, and maintainability.
My opinion is that you shouldn’t worry about these micro optimizations unless you need to.