[Python] is there any downside to creating lots of class instances?

Discussão em 'Python' iniciado por Stack, Março 15, 2025.

  1. Stack

    Stack Membro Participativo

    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?

    Continue reading...

Compartilhe esta Página