I have lots of variables to keep track of in my game, and I'm wondering if there's any downside to creating lots of class instances:
event_1 = event(name, chance, [people])
event_2 = event(name, chance, [people])
...
events = [event_1, event_2]
instead of just creating a nested list?
events = [
[name, chance, [people]],
[name, chance, [people]],
...
]
other than the trading some instance names for ease of use in the case of classes, should I be worried about something like performance penalties or anything like that?
Edit: I mentioned the ease of use, what I'm wondering is: do classes in a list use more resources than a nested list or it's the other way around?
My advice would be to first optimise for readability and maintainability of your code. Focus on performance only when it demonstrably becomes an issue. Once you know it's an issue, you'll be able to measure the system in its entirety, identify bottlenecks and fix them.
You may find that:
With this in mind, I would favour the first approach over the second.