1

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.

alexis
  • 48,685
  • 16
  • 101
  • 161
  • 2
    I am not aware of any such limits, however if you have a matrix with many many rows you should really be using numpy and the `.T` property for transpose, not mucking around with zips and splats. – wim Sep 30 '14 at 16:44
  • Thanks, the answers to the linked question cover it between them (or by implication). @wim, I didn't plan to. The idiom made me nervous, so I wanted to know the facts. – alexis Sep 30 '14 at 17:15

0 Answers0