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!
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
inif there is a instance already, one could just useif not instances?I believe the memory usage would be lower then and I guess a single instance is all the metaclass should expect.
Thanks!