Data Structure Selection

May 30, 2026 | 5 min read

Numeric Arrays: list

Use list for homogeneous numeric sequences.

Key-Value Lookups: dict

dict is highly optimised for compiled code.

Immutable Records: tuple

tuple has lower overhead than list for read-only data.

Avoid: Mixed-Type Collections

bad = [1, "two", 3.0]  # boxed objects

Avoid: Nested Deep Structures

Shallow structures compile faster than deeply nested dicts of lists of dicts.