8 May
2018
8 May
'18
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>