How Strings Compile

May 30, 2026 | 5 min read

Concatenation

+ with two strings allocates and copies.

Slicing

s[start:end] creates a new string substring.

Comparison

== uses memcmp for equal-length strings.

Formatting

f-strings compile to concatenation chains.