Last active
March 9, 2026 13:13
-
-
Save akaIDIOT/f5de7c491bf21ab44e3a88591c2175df to your computer and use it in GitHub Desktop.
Enable some optional but useful features of Python through environment variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This file is intended to be sourced by a shell, not doing anything by | |
| # default, but adding functions "full-monty" and "no-monty" as enabler and | |
| # disabler respectfully of some useful features in Python through environment | |
| # variables. Put it somewhere like /etc/profile.d/ or the likes. Or don't 🤷 | |
| # | |
| # See https://docs.python.org/3/using/cmdline.html#environment-variables | |
| full-monty() { | |
| # run in optimized mode, removing assert and debug code | |
| export PYTHONOPTIMIZE=1 | |
| # use UTF-8 as the default encoding basically everywhere | |
| export PYTHONUTF8=1 | |
| # use colors where supported (3.13+) | |
| export PYTHON_COLORS=1 | |
| # attempt to disable the GIL (3.13+) | |
| export PYTHON_GIL=0 | |
| # enable the JIT compiler (3.13+) | |
| export PYTHON_JIT=1 | |
| # make lazy imports the default (3.15+) | |
| export PYTHON_LAZY_IMPORTS=all | |
| } | |
| no-monty() { | |
| unset PYTHONOPTIMIZE | |
| unset PYTHONUTF8 | |
| unset PYTHON_COLORS | |
| unset PYTHON_GIL | |
| unset PYTHON_JIT | |
| unset PYTHON_LAZY_IMPORTS | |
| } | |
| export -f full-monty | |
| export -f no-monty |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment