I am trying to use a simple list with del a[0]
to mimic the deque.popleft()
. Just want to understand how does del
in Python work. For example:
a = [0,1,2,3,4,5]
a
is in a continuous space in memory. After I call del a[0]
, will Python allocate new space and copy 1,2,3,4,5
there, or it will just give a
a new address (which is same as a = a[1:]
).
If it allocates new space, does it mean del a[0]
is a _O (len (a) _ operation?
If del a[0]
is the same as a = a[1:]
, will Python reclaim the memory space that has been deleted from the array?