"""Module providing singleton decorator function"""


def singleton(class_):
    """Enforces unique instantiation. To be used as class decorator"""

    instances = {}

    def get_instance(*args, **kwargs):
        if class_ not in instances:
            instances[class_] = class_(*args, **kwargs)
        return instances[class_]

    return get_instance
