#Python 3, 13 byte source, 9,057,900,463 byte (8.5GiB) .pyc-file
Python 3, 13 byte source, 9,057,900,463 byte (8.5GiB) .pyc-file
(1<<19**8,)*2
Edit: Changed the code to the version above after I realized the rules say output size beyond 4GiB doesn't matter, and the code for this one is ever so slightly shorter; The previous code - and more importantly the explanation - can be found below.
#Python 3, 16 byte source, >32TB .pyc-file (if you have enough memory, disk space and patience)
Python 3, 16 byte source, >32TB .pyc-file (if you have enough memory, disk space and patience)
(1<<19**8,)*4**7
Explanation: Python 3 does constant folding, and you get big numbers fast with exponentation. The format used by .pyc files stores the length of the integer representation using 4 bytes, though, and in reality the limit seems to be more like 2**31
, so using just exponentation to generate one big number, the limit seems to be generating a 2GB .pyc file from an 8 byte source. (19**8
is a bit shy of 8*2**31
, so 1<<19**8
has a binary representation just under 2GB; the multiplication by eight is because we want bytes, not bits)
However, tuples are also immutable and multiplying a tuple is also constant folded, so we can duplicate that 2GB blob as many times as we want, up to at least 2**31
times, probably. The 4**7
to get to 32TB was chosen just because it was the first exponent I could find that beat the previous 16TB answer.
Unfortunately, with the memory I have on my own computer, I could test this only up to a multiplier of 2, ie. (1<<19**8,)*2
, which generated a 8.5GB file, which I hope demonstrates that the answer is realistic (ie. the file size isn't limited to 2**32=4GB).
Also, I have no idea why the file size I got when testing was 8.5GB instead of the 4GB-ish I expected, and the file is big enough that I don't feel like poking around it at the moment.