def __new__(cls, obj, *args, **kwargs):
    """Create an proxy instance referencing `obj`.

        (obj, *args, **kwargs) are passed to this class' __init__, so deriving classes can define an
        __init__ method of their own.

        _class_proxy_cache is unique per deriving class (each deriving class must hold its own cache).

        Args:
            obj (object): Instance of the class in which we want to use the proxy.
            *args: Variable length argument list.
            **kwargs: Arbitrary keyword arguments.

        Returns:
            object: New proxy instance referencing `obj`.
        """
    try:
        cache = cls.__dict__['_class_proxy_cache']
    except KeyError:
        cls._class_proxy_cache = cache = {}
    try:
        the_class = cache[obj.__class__]
    except KeyError:
        cache[obj.__class__] = the_class = cls._create_class_proxy(obj.
            __class__)
    instance = object.__new__(the_class)
    the_class.__init__(instance, obj, *args, **kwargs)
    return instance
