Site Unseen: hidden python customization
- Level:
- beginner
- Room:
- north hall
- Start:
- Duration:
- 30 minutes
Abstract
Python offers us the ability to customize how it starts up. In some cases arbitrary python code can get executed before the first line of your module is reached. This is necessary for some of its dynamic nature, like virtualenvs but can also be harnessed to make the interpreter experience truly personal.
Description
Python does a lot of work to customize itself when starting up. It also provides hooks for even more customization from users and packages during startup. Some of these are on by default while others must be enabled. Learn how to take advantage of Python's startup to craft a custom interpreter.
Python has a dizzying array of environment variables, many of which are used for startup tuning. The list has grown so long that recent Python versions have split the description of these variables into their own help (--help-env). It is valuable to a Pythonista to know about all of these, but this talk will show you how to use a subset to personalize the Python runtime environment to your development needs and preferences.
As powerful as this customization is, much of it is possible through arbitrary code execution or otherwise manipulating the expected behavior of lookups. Since many of these behaviors happen automatically, it is important to know how to disable them for many reasons: security, reproducibility, and speed among them.