Thought experiment about adding extra loadable stuff to a .pyc file

I note that the rest of the .pyc file is also bytecode generated by the compiler and tightly coupled to it. So I’m not sure what you’re getting at here. It’s not like that’s a downside for my proposal.

If you’re suggesting that tightly-coupled-to-the-compiler is a misfeature, and you’d prefer an alternate approach that would be Python-version-independent, by all means propose one! But that wasn’t one of my goals.

Again, my use case was literally for data generated by the Python compiler as it went about its work, that we might want to make lazy-loaded, so we don’t waste memory on it in the likely scenario that we don’t need it at runtime. I think my proposal is a reasonable approach to solving that problem. Solving my problem didn’t need version independence, backwards/forward compatibility, etc.