exaloop / codon

A high-performance, zero-overhead, extensible Python compiler using LLVM
https://docs.exaloop.io/codon
Other
13.96k stars 498 forks source link

Argument unpacking with `*` not supported #506

Closed akleemans closed 5 months ago

akleemans commented 6 months ago

Somehow argument unpacking does not work:

arr = [1, 2]
print(*arr)

Error: error: argument after * must be a tuple, not 'List[int]' (Codon version 0.16.3)

Is there any way to do this?

For the print()-case above I could find a workaround, but if I want to use e.g. math.lcm(*integers) with a list of variable length, I see no possible solution.

inumanag commented 5 months ago

You cannot unpack lists in Codon, unfortunately, as list length is not known at compile time; you can only unpack tuples. You need to either cast list to tuple or have an arbitrary way to pass lists to functions.

This limitation won't go away; it is intrinsic to Codon's static compilation approach.