How Lists Compile

May 30, 2026 | 5 min read

Creation

[a, b, c] allocates a list and fills it inline.

Indexing

list[i] uses fast bounds-checked access.

Append

list.append(x) amortised growth with over-allocation.

Comprehension

[x for x in data] compiles to a pre-allocated loop.