What are the consequences of really big primitive types?

one can declare arbitarily large primative types using the primative keyword.
As far as i can tell they act like well behaved isbits types, no matter how large you make them.

BitIntegers.jl uses this to allow the creation of arbitarily large integer types. like Int1024

ShortStrings.jl in turn uses them to allow arbitarily large “short” strings, that are efficiently stored inline as nibbles within the numbers.

Now i have tried ShortStrings backed by Int2048 and that seemed fine.
When i tried a ShortString backed by a Int10240 that was less OK, and my computer basically froze up for 10 minutes when i tried to do things with it.

So what are the properties and imitations of primitive types that are large?
The largest ones in Base (AFAIK) are Int128 and UInt128.

12 Likes

One thing I discovered while investigating https://github.com/rfourquet/BitIntegers.jl/issues/13 is that for bitshifts, LLVM first converts both operands to the same type. This means that in rand(Int1024) << 0x3, the 0x3 will be converted to Int1024. I have no idea why, maybe for small primitives it makes sense, but it might be (one of) the cause of inefficient bit-shifting for big primitives.

6 Likes