arte/utils/multiton.py
def multiton_id(cls):
    '''
    Multiton decorator for mutable types

    Decorator that returns the same instance of a class
    every time it is instantiated with the same parameters.

    Similar to "multiton", but uses the id of each argument
    to build an hashable key. This allows to pass things
    like dictionaries that will be recognized as identical even
    if their contents change, but risks not recognizing identical
    values of strings and numbers.
    As a side effect, the class name becomes a function
    that returns an instance, rather than a class type instance.
    '''
    instances = {}

    def getinstance(*args):
        ids = [str(id(x)) for x in args]
        key = '.'.join(ids)
        if key not in instances:
            instances[key] = cls(*(args[1:]))
        return instances[key]

    return getinstance

    Multiton decorator for mutable types

    Decorator that returns the same instance of a class
    every time it is instantiated with the same parameters.

    Similar to "multiton", but uses the id of each argument
    to build an hashable key. This allows to pass things
    like dictionaries that will be recognized as identical even
    if their contents change, but risks not recognizing identical
    values of strings and numbers.
    As a side effect, the class name becomes a function
    that returns an instance, rather than a class type instance.
    
Multiton decorator for mutable types
Decorator that returns the same instance of a class
every time it is instantiated with the same parameters.

Similar to "multiton", but uses the id of each argument
to build an hashable key. This allows to pass things
like dictionaries that will be recognized as identical even
if their contents change, but risks not recognizing identical
values of strings and numbers.
As a side effect, the class name becomes a function
that returns an instance, rather than a class type instance.
Multiton decorator for mutable types Decorator that returns the same instance of a class every time it is instantiated with the same parameters . Similar to " multiton " but uses the id of each argument to build an hashable key . This allows to pass things like dictionaries that will be recognized as identical even if their contents change but risks not recognizing identical values of strings and numbers . As a side effect the class name becomes a function that returns an instance rather than a class type instance .
def multiton_id(cls):
    instances = {}
    def getinstance(*args):
        ids = [str(id(x)) for x in args]
        key = '.'.join(ids)
        if key not in instances:
            instances[key] = cls(*(args[1:]))
        return instances[key]
    return getinstance
def multiton_id ( cls ) : instances = { } def getinstance ( * args ) : ids = [ str ( id ( x ) ) for x in args ] key = '.' . join ( ids ) if key not in instances : instances [ key ] = cls ( * ( args [ 1 : ] ) ) return instances [ key ] return getinstance
Multiton decorator for mutable types
Decorator that returns the same instance of a class
every time it is instantiated with the same parameters.
Multiton decorator for mutable types Decorator that returns the same instance of a class every time it is instantiated with the same parameters .
'''
    Multiton decorator for mutable types

    Decorator that returns the same instance of a class
    every time it is instantiated with the same parameters.

    Similar to "multiton", but uses the id of each argument
    to build an hashable key. This allows to pass things
    like dictionaries that will be recognized as identical even
    if their contents change, but risks not recognizing identical
    values of strings and numbers.
    As a side effect, the class name becomes a function
    that returns an instance, rather than a class type instance.
    '''
cls