I will try to clarify:
For example, I create a function that locally creates a list and returns it. How does Python create a return list that exists outside the function body? Does it use "deepcopy" (or something like that)?
In [50]: def create_list():
...: sublist1 = [1,2,3]
...: sublist2 = [4,5,6]
...: list_of_lists=[sublist1,sublist1,sublist2]
...: return list_of_lists
...:
In [51]: l=create_list()
In [52]: l
Out[52]: [[1, 2, 3], [1, 2, 3], [4, 5, 6]]
In [53]: l[0].append(4)
In [54]: l
Out[54]: [[1, 2, 3, 4], [1, 2, 3, 4], [4, 5, 6]]
Here, the returned list lstill contains sublists. And l[0]and l[1]still refer to the same sublist (which is Python's usual behavior). Thus, the list and its structure were copied.
And if I call again create_list():
In [55]: l2=create_list()
In [56]: l2
Out[56]: [[1, 2, 3], [1, 2, 3], [4, 5, 6]]
In [57]: l
Out[57]: [[1, 2, 3, 4], [1, 2, 3, 4], [4, 5, 6]]
l2, l , , , , , .
, : Python deepcopy - , l?
, , ?
( , )
, .
,