Lists, Tuples, Copying & Comprehensions

Unit 3: Built-in Data Structures & Hashing · 8 min read

Dynamic array resizing costs, single-element tuple syntax, shallow vs deep copy aliasing, and readable list comprehensions.

Key Concepts

  • O(1) append/pop() vs O(n) insert(0)/pop(0)
  • The [[0]*n]*m nested list multiplication bug
  • list.sort() returns None vs sorted() returns new list
  • Unpacking with starred targets: head, *mid, tail = seq

Official Python Docs

Back to Python Notes Hub