Runtime v2.81 · Updated Sep 30, 2026

sum

Return the numeric sum of an iterable, optionally starting from start.

Syntax

sum(iterable, /, start=0)

Parameters

NameDescription
iterablelist | tuple | set | generator
Iterable containing numeric values.
Required · Positional only
No default
startNumber
Initial value added before iterable items.
Optional · Positional or named
Default: 0

Returns

Number — Total numeric value.

Behavior / side effects

Return the numeric sum of an iterable, optionally starting from start. A generator expression can omit its own parentheses only when it is the sole argument of a function or method call; extra arguments or a trailing comma require parentheses around the generator.

Execution

  • Blocking: No
  • Thread safety: Use separate objects per flow
  • Parallel execution: Yes

Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.

Example

# Sum generated values
values = [1, 2, 3]
total = sum(value * 2 for value in values)
with_start = sum((value * 2 for value in values), start=10)
text(str(total))
text(str(with_start))

Errors / limitations

No additional limitations documented; follow the parameter and behavior contract above.

Related APIs

None