from abc import ABCMeta


class Singleton(type):
    _instances = {}
    
    def __call__(cls, *args, **kwargs):
        # Create new instance if it doesn't exist
        if cls not in cls._instances:
            cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
        return cls._instances[cls]
    

class BaseSingleton(metaclass=Singleton):
    pass


class SingletonABCMeta(ABCMeta):
    _instances = {}

    def __call__(cls, *args, **kwargs):
        # Create new instance if it doesn't exist
        if cls not in cls._instances:
            instance = super().__call__(*args, **kwargs)
            cls._instances[cls] = instance
        return cls._instances[cls]
    

class BaseSingletonABC(metaclass=SingletonABCMeta):
    pass
