STINNER Victor <vstin...@python.org> added the comment:
The same problem exists at the function level: see bpo-39805: "Copying functions doesn't actually copy them". For example, copy.deepcopy(func) returns func unchanged if it's a function. Example: --- import copy def make_closure(): closure = [] def append(value): closure.append(value) return append, closure func, closure = make_closure() func(1) func2 = copy.deepcopy(func) func2(2) print(func2 is func) print(closure) --- Output: --- True [1, 2] --- ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue47143> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com