from timeit import timeit
n = 1024 * 1024
while n > 1:
    print('-' * 30, n)
timeit('s.appendleft(37)', 'import collections; s = collections.deque()',
    number=n)
timeit('s.insert(0,37)', 's = []', number=n)
n >>= 1
Efficiency of using a Python list as a queue