MemotivaPerformance and profiling

What is the difference between time complexity of list and dict operations?

Performance and profiling

Audio flashcard · 0:17

Nortren·

What is the difference between time complexity of list and dict operations?

0:17

List access by index, append, and pop from the end are constant time. Insertion and deletion at the front are linear time. Membership testing is linear time. Dict access, insertion, and deletion are average constant time, as is membership testing. For frequent membership tests, prefer sets or dicts over lists.
wiki.python.org