CKTIS / Python
itertools.starmap
Unpacks each input row into positional arguments for a function.
Version: Python 3.14; repository image, production runtime not attested
Syntax
itertools.starmap(function, iterable, /)Unpacks each input row into positional arguments for a function.
Each row must match the function’s calling convention. Empty input calls the function zero times.
Reading the iterator unpacks each input row into positional arguments. pow(2, 3) gives 8 and pow(3, 2) gives 9. Construction alone does not call the function. Empty input makes no calls, while a row with unsuitable arity raises TypeError when reached.
import itertools as I
calls = []
def f(a, b):
calls.append((a, b))
return a + b
it = I.starmap(f, [(2, 3)])
assert not calls and next(it) == 5 and calls == [(2, 3)]
Examples
import itertools as I
print(list(I.starmap(pow, [(2, 3), (3, 2)])))
print(list(I.starmap(pow, [])))
Result
[8, 9] []
Reading the iterator unpacks each input row into positional arguments. pow(2, 3) gives 8 and pow(3, 2) gives 9. Construction alone does not call the function. Empty input makes no calls, while a row with unsuitable arity raises TypeError when reached.