Large inline list literals compile extremely slowly

Defining a large list inline causes Mojo to compile extremely slowly, while the equivalent Python code executes instantly.

Both var and comptime approaches exhibit this issue:

fn main():
    var PROGRAM = [0x0, 0x0, 0x0, …] # ~10k elements
    for byte in PROGRAM:
        print(byte, end=" ")

Godbolt link: Compiler Explorer

Hi

I’d like to clarify, does the compiler eventually finish (just very slowly), or does it crash?

It doesn’t crash. I think it eventually finishes but after a loooong time

Reminds me of GitHub - gonsolo/swift_bugs

@shuklaayush Do you mind filing a bug report on GH?

Sure, I created one here: [BUG] Large inline list literals compile extremely slowly · Issue #5632 · modular/modular · GitHub

1 Like

Thank you!