T-uple max size

I've read a few posts on this, but did not get a precise answer. I was wondering what is the max size of a t-uple (in the latest Swift version).

I believe that 32 bits are used in the compiler to represent the number of elements in a tuple, so that (2**32 - 1) is one upper bound. Someone else will need to comment if there's a tighter constraint enforced elsewhere.

Thanks.
There is probably a tighter constraint.
I read (SO I think) that limit in Xcode 6 (Swift 3 ?) was 1948 items.

2**20 compiles, but 2**20 + 1 crashes compiler
I checked with the following python code:

size = 2**20
print("let x: Int = 0")
print("let bigTuple: (", end = '')
for i in range(size):
    print("Int,", end = '')
print("Int) = (", end = '')
for i in range(size):
    print("x,", end = '')
print("x)")
2 Likes

Please file a bug; we should be enforcing any limits we want to impose.

2 Likes

Filed! https://bugs.swift.org/browse/SR-11747

1 Like
Terms of Service

Privacy Policy

Cookie Policy