Runtime Complexity of Python List Methods [Easy Table Lookup]

What’s the runtime complexity of various list methods?

The following table summarizes the runtime complexity of all list methods.

Assume that the length of the data type is defined as n (that is—len(data_type)). You can now categorize the asymptotic complexity of the different complexity functions as follows:

OperationExampleComplexity
Indexl[i]O(1)
Storel[i] = 42O(1)
Lengthlen(l)O(1)
Appendl.append(42)O(1)
Popl.pop()O(1)
Clearl.clear()O(1)
Slicingl[a:b]O(b-a)
Extendl1.extend(l2)O(len(l1)+len(l2))
Constructorlist(iter)O(len(iter))
Equalityl1 == l2O(n)
Slice Assignl[a:b] = ...O(n)
Deletedel l[i]O(n)
Removel.remove(...)O(n)
Membershipx in l / x not in lO(n)
Copyl.copy()O(n)
Popl.pop(0)O(n)
Minmin(l)O(n)
Maxmax(l)O(n)
Reversel.reverse()O(n)
Iteratefor x in l:O(n)
Sortl.sort()O(n log(n))
Multiplyl*kO(n k)

Need to learn more about these methods? Watch me giving you a quick overview of all Python list methods:

You can read more about all methods in my detailed tutorial on the Finxter blog.

Here’s your free PDF cheat sheet showing you all Python list methods on one simple page. Click the image to download the high-resolution PDF file, print it, and post it to your office wall:

Where to Go From Here?

Enough theory. Let’s get some practice!

Coders get paid six figures and more because they can solve problems more effectively using machine intelligence and automation. To become more successful in coding, solve more real problems for real people. That’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

You build high-value coding skills by working on practical coding projects!

Do you want to stop learning with toy projects and focus on practical code projects that earn you money and solve real problems for people?

If your answer is YES!, consider becoming a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!