alexis
alexis

Reputation: 50210

How robust is `func(*argument)`?

In python, you can expand a sequence into discrete function arguments with the star operator:

args = [2, 3]
print(pow(*args))  # same as `print(pow(2, 3))`

There's even a nice idiom for transposing a matrix (a list of lists), like this: zip(*matrix). Since the matrix could have many, many rows, I wonder: How robust is the star-expansion of very long sequences into arguments? In many languages, explicit argument lists (f(a1, a2, a3, ..., ..., ...)) have length limits well below array length limits.

Are there such limits in (popular implementations of) python, and are star-expanded arguments handled in a way that prevents hitting against such limits? (E.g., if they are directly stuffed into an argument vector for a function with signature like def function(*args)). Is this an implementation-dependent issue, or are there guarantees about what can be handled? I dug around the python documentation a bit but I was not able to find discussion of this.

Upvotes: 1

Views: 62

Answers (0)

Related Questions