Raymond Hettinger added the comment:
> If you pickle also hard refereces to the items,
> a WeakSet can be pickled and unpickled as expected (after
> fixing __reduce__).
That seems contrary to the original intent of a WeakSet. I recommend not going
down the path of adding pickle support.
If
Serhiy Storchaka added the comment:
The method is broken (and always was). Pickling doesn't work because the state
contains unpickleable object. Copying works incorrectly, since the pickle state
contains references to the original WeakSet and it overrides the __dict__ of
the copy, making its s
Raymond Hettinger added the comment:
> I wondering whether WeakSet should be made pickleable or
> the __reduce__ method should be removed.
When considering whether to remove a method from long published code, if the
method isn't broken, our guidance should come from whether user's have actuall
New submission from Serhiy Storchaka:
WeakSet contains the __reduce__ method, but it isn't pickleable (and never
was), because the pickle state contains the value of the __dict__ dict
attribute which contains a reference to unpickleable local function _remove().
>>> pickle.dumps(weakref.WeakSe