I am learning to use list and slicing and have read that "slices of Python lists create new objects in memory" in the section "Memory Considerations:" by Aaron Hall in Understanding Python's slice notation
Let's say I need to do some read-only operation in some range of a list. Is it recommended to use pointer (c term), because slicing creates new object that I do not need? Assuming that the original list won't be changed, can I say the method2 below is always better?
cost = [1,2,4,5]
#method1
for i in cost[:2]:
#do something for the first two elements
print(i)
#method2
for i in range(2):
#do something for the first two elements
print(cost[i])