Skip to content

CSP-P003: String Concatenation in Loop

Category: Performance

Severity: LOW

Description

Repeated string concatenation in a loop can be quadratic. Use join().

Vulnerable Code Example

out = ""
for x in items:
    out += str(x)

Safer Code Example

out = "".join(str(x) for x in items)

How to Suppress a Finding

# ignore
# or
# noqa: CSP-P003