There are two other considerations here that have nothing to do with speed and which contradict one another:
- Do you really want your entire program to know that a certain setting is picked up from the environment? I usually view the environment as a configuration type interface: Load from it once only so I can change the source of a setting later if needed.
- On the opposite side: If a value is known to be environmental, can any other parts of the program (e.g., used packages) set it? If so, then taking it once may have the wrong effect if someone tries to set it later, expecting that later setting to have some effect.
These are mostly maintenance/large program considerations. So if this is a simple script, you can probably disregard them as factors. For large systems I tend to take the approach that hides data sources and manipulations the most since it makes longer term changes easier.