On Tue, 2021-09-28 at 10:22 +0200, Marc-Andre Lemburg wrote:
On 27.09.2021 18:51, Eric Snow wrote:
We've frozen most of the stdlib modules imported during "python -c pass" [1][2], to make startup a bit faster. Import of those modules is controlled by "-X frozen_modules=[on|off]". Currently it defaults to "off" but we'd like to default to "on". The blocker is the impact on contributors. I expect many will make changes to a stdlib module and then puzzle over why those changes aren't getting used. That's an annoyance we can avoid, which is the point of this thread.
Possible solutions:
1. always default to "on" (the annoyance for contributors isn't big enough?) 2. default to "on" if it's a PGO build (and "off" otherwise) 3. default to "on" unless running from the source tree
Thoughts?
#3 sounds like a good solution, but how would you detect "running from the source tree" ? This sounds like you need another stat call somewhere, which is what the frozen modules try to avoid.
It does. FYI, here's the sysconfig implementation https://github.com/python/cpython/blob/main/Lib/sysconfig.py#L146-L181 But a more efficient way to do this could be added.
I'd like to suggest adding an environment variable to enable / disable the setting instead. This makes it easy to customize the behavior without introducing complicated logic.
From your followup reply, it seems like you are suggesting that it should be enabled by default, and use a env var to disable it. That would have the same problem regarding the annoyance of contributors. Is there any reason why you would prefer that over #2? That seems like the best option to me if #3 is not feasible. Cheers :) Filipe Laíns