# How is del array[position] really implemented in Python?

I was expecting that executing `del v[i]` to remove the i-th entry of an array `v` would take linear time (O(n) where `n = len(v)`), because it is necessary to copy the array to a new array in order to keep the indexes correct.

Therefore, the time spent by `del v[i]` and by copying `v` to a new array should be more or less equivalent.

However, when I execute the following code with Python3, I get the output below:

``````from timeit import default_timer as time

n = 2**25
position = 10

start = time()
v = [i % 2 for i in range(n)]
end = time()
print("%f seconds to create the array." % (end - start))

start = time()
u = v.copy()
end = time()
print("%f seconds to copy the array." % (end - start))

start = time()
del v[position]
end = time()
print("%f seconds to delete %d-th entry." % (end - start, position))
``````

Output:

2.289337 seconds to create the array.

0.140918 seconds to copy the array.

0.026342 seconds to delete 10-th entry.

As you can see, deleting an entry takes about 18% of the time needed to copy the array.

Interestingly, if I change the variable position above to small negative values (like -1, -10, -100, or -1000), then the time to delete is almost zero, that is, only 0.000001 seconds.

So, how is del really implemented to arrays and what is its actual time complexity?