Skip to content

Prefer tuples to lists

Anthony Sottile edited this page Oct 24, 2017 · 1 revision

tuples are:

  • smaller (they don't need additional bookkeeping for size, capacity, unfilled space)
  • faster (they can be stored directly in the code object, and are smaller to allocate)
  • and best of all immutable (awww yissss)

so whenever equivalent, tuples should always be preferred