for x in range(size):
    res.append(x)
FUNCS = [['list', normal], ['pre-allocate', prealloc], ['deque', deq]]
size = 10
while size <= 10000000:
    print('size: {0}'.format(size))
for n, f in FUNCS:
    start = time.clock()
for i in range(30):
    f(size)
t = time.clock() - start
print('{}: {}'.format(n, t / 30))
size *= 100
print('')
Python: A list that doesn't get relocated