Bar Harel added the comment: Alright. 2 patches are available.
opt_1 makes the use of __copy__. Advantages: - Clean - Does not affect pickling at all - More memory efficient Disadvantages: - Might be missing something from the normal copy mechanism (e.g. UserList doesn't implement __slots__ but it somewhat interferes with future implementation) - Doesn't call __reduce__, __getstate__, ... while people might rely on it for some reason during copy, thus it might not be entirely backwards compatible opt_2 makes use of __reduce__. Advantages: - Lowest in the chain. Shouldn't cause any backwards compatibility issues as if the user manually defined __getstate__ or __reduce_ex__ himself, the code as far as he's concerned did not change. - Uses the default mechanism for copying. Changes in the protocol will not cause any bug in here. Disadvantages: - Affects pickling, messes up with the __reduce__ protocol. - Takes more memory during pickling as it recreates the dict. - Uglier as a personal opinion. __getstate__ was not attempted as it will break backwards compatibility for sure if someone wrote a __reduce__ method (as it won't be called), but it's also a viable option. Both patches contain tests and both fix the bug in UserDict and UserList. ---------- versions: +Python 3.7 Added file: http://bugs.python.org/file44832/issue27141_patch_rev1_opt1.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27141> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com