Weakref proxy is for instance only ...
Proxy cannot be created for basic datatypes like list, dict, str and int. Proxy can be create for class instances only. Also proxy cannot be created for proxy of another instance. >>> import weakref >>> a = 'str' >>> b = weakref.proxy(a) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: cannot create weak reference to 'str' object >>> a = 1 >>> b = weakref.proxy(a) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: cannot create weak reference to 'int' object >>> a = [] >>> b = weakref.proxy(a) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: cannot create weak reference to 'list' object >>> a = {} >>> b = weakref.proxy(a) Traceback (most recent call last): File "<stdin>",...