jasily/lang/proxy.py
def mutable(obj):
    '''
    return a mutable proxy for the `obj`.

    all modify on the proxy will not apply on origin object.
    '''
    base_cls = type(obj)

    class Proxy(base_cls):
        def __getattribute__(self, name):
            try:
                return super().__getattribute__(name)
            except AttributeError:
                return getattr(obj, name)

    update_wrapper(Proxy, base_cls, updated = ())
    return Proxy()
def mutable(obj):
    '''
    return a mutable proxy for the `obj`.

    all modify on the proxy will not apply on origin object.
    '''
    base_cls = type(obj)

    class Proxy(base_cls):
        def __getattribute__(self, name):
            try:
                return super().__getattribute__(name)
            except AttributeError:
                return getattr(obj, name)

    update_wrapper(Proxy, base_cls, updated = ())
    return Proxy()
return a mutable proxy for the `obj`.

    all modify on the proxy will not apply on origin object.