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!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And 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?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become 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!