Suppose I have a function which returns a modified version of an input, say a sorting algorithm:
def insertion_sort(listToSort):
for itemToSort in range(1, len(listToSort)):
for i in range(itemToSort, 0, -1):
if listToSort[i] < listToSort[i-1]:
listToSort[i], listToSort[i-1] = listToSort[i-1], listToSort[i]
else:
break
Usually I'd expect that I need to return the new modified version. But in Python, it seems like actual parameters are not a copy of the input, but instead a "link" to the input. This is different from other languages I've worked with (C#, C++), is there a reason this choice was made or was it an arbitrary one?