Skip to main content

O(n²) string concatenation

A CSV renderer that builds the output with `+=`. Looks fine; runs slow on a 100k-row job. What does a senior flag FIRST?

The snippet

# Render a list of rows as CSV. Slow at 100k rows.

def render_csv(rows):
    out = ""
    for row in rows:
        out += ",".join(str(c) for c in row) + "\n"
    return out

What would a senior flag FIRST?