I want to limit the length of the list in python, whenever len(list) > limit, the first item will be removed, I knew collection.deque can achieve the same way, however, will it be slower than just do something like:
list_A = [2,4,6,8,11]
length_limit = 5
while True:
# do something to the list, for example, list_A.append(2)
if len(list_A) > length_limit:
list_A = list_A[1:]
And besides, do something like this or collection.deque, is any other way to achieve it much readable and efficient?