Problem scenario
You use del and pop to remove items from lists. You noticed that pop is slower than del. Why is this the case?
Solution
There are two reasons. One, pop returns the value that is removed. Two, pop acts as a function call as opposed to a primitive action. Whereas the del invokes a primitive action (a non-recursive function call),
…
Continue reading “When Manipulating Lists in Python, Why is pop Slower than del?”