Skip to content

Doubt about using a dictionary to hold instances #1

@glasswalk3r

Description

@glasswalk3r

Hi there! Thanks for sharing your code!
I'm studying different implementations of Singleton in Python and found out that the most efficient use would be using a Metaclass.
I have one doubt, if you don't mind answering, about why did you choose a dictionary to hold the instances. Wouldn't a single scalar variable be enough for that?
So, instead of checking with in if there is a instance already, one could just use if not instances?
I believe the memory usage would be lower then and I guess a single instance is all the metaclass should expect.
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions