frozenset.copy() does not create a copy
4 May
2018
4 May
'18
12:47 p.m.
Tried it in Python 2.7 and found that it just creates an alias to the original set.
8 May
8 May
8:28 a.m.
On Tue, May 8, 2018 at 5:20 PM Mihail Temelkov <mtemelkov@gmail.com> wrote:
Tried it in Python 2.7 and found that it just creates an alias to the original set.
In Python, copy() or similar methods may return itself for immutable types. It's widely used optimization.
t=(1,2) t1=(1,2) t2=t1[:] t1 is t2 True
And it is implementation (CPython) specific optimization; other implementation may return new instance. You shouldn't rely on undocumented behavior. Regards, -- INADA Naoki <songofacandy@gmail.com>
2431
Age (days ago)
2435
Last active (days ago)
1 comments
2 participants
participants (2)
-
INADA Naoki
-
Mihail Temelkov