New submission from Svyatoslav <[email protected]>:
from copy import copy, deepcopy
t = 1, 2
t1 = t, 3
t2 = t1, 4
t3 = t2, 5
assert copy(t3) is t3
assert deepcopy(t3) is t3
s = frozenset({1, 2})
assert s.copy() is s # method .copy() always returns self, what its purpose?
assert copy(s) is s
assert deepcopy(s) is s # raises AssertionError
Even a deepcopy of a tuple with many nested tuples is the the tuple itself,
while a deepcopy of a frozenset which by definition cannot contain mutable
objects is a new frozenset.
I think it is an error. A new frozenset is created because deepcopy() fallbacks
to pickling.
----------
components: Library (Lib)
messages: 397961
nosy: Prometheus3375
priority: normal
severity: normal
status: open
title: deepcopy(frozenset()) returns a new object
versions: Python 3.9
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue44703>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com