On Mon, Sep 27, 2021 at 6:58 PM Eric Snow <ericsnowcurren...@gmail.com> 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?

Honestly, for me, #1: always on, is the most reasonable choice.

I dislike when Python behaves differently depending on subtle things
like "was it built with optimizations" or "is Python started from its
source tree"?

When I built Python without optimization and/or from its source tree,
I do that to debug an issue. If the bug goes away in this case, it can
waste my time.

So I prefer to teach everybody how to use "-X frozen_modules=off" if
they want to hack the stdlib for their greatest pleasure. I prefer
that such special use case requires an opt-in option, the special use
case is not special enough to be the default.

--

It means that the site module module can no longer be "customized" by
modifying directly the site.py file (inject a path in PYTHONPATH env
var where the customized site.py lives). But there is already a
supported way to customize the site module: create a module named
"sitecustomize" or "usercustomizer". I recall that virtualenv likes to
override stdlib site.py with its own code. tox uses virtualenv by
default. Someone should check if freezing site doesn't break
virtualenv and tox, since they seem to be popular in Python. The venv
doesn't need to override site.py and tox can use venv if I recall
correctly.

If site.py customization is too popular, I would suggest to not freeze
this one, until the community stops doing that.

Victor
-- 
Night gathers, and now my watch begins. It shall not end until my death.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/FWAYUPG5DRRHFULNPXQOZF3NR6QZ37K2/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to