-
Notifications
You must be signed in to change notification settings - Fork 29.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
os: make tmpdir
be const value
#1648
Conversation
Couldn't |
@brendanashworth I recall python's |
With environment variables read only once at startup, it should currently behaves as a constant, unless the user changes the variables during runtime (unlikely), which we would take away the ability to do so. |
@silverwind Could a variable in |
@ChALkeR yes it can. |
It is a function, after all: |
The process gets a snapshot of the environment on startup and the only way for it to change is through assignment to |
@silverwind If that is true, why not take a snapshot `process.env` as a
simple js object at startup? Atm, `process.env.foo` is much slower than it
would be if that was converted to an object.
But can't some native code call `setenv("foo", "bar")` and expect
`process.env.foo` to be changed on the js side?
|
-1. In most usage patterns it is cached anyway |
Closing for now, seems like the consensus is this isn't too great, and you can cache it yourself where applicable in programs. :) |
Just a small documentation update, if you're open to it. Suggesting that `NODE_ENV` be "cached" in the example `unsafeValidate` method. Reasoning / discussions here: * nodejs/node#3104 * nodejs/node#1648 Unless you'd expect `NODE_ENV` to be editable while the application is running (debugging on a live server, perhaps?)
This patch also make the function
getTmpdir()
be called once with a little improvement, but the main purpose of this PR is to maketmpdir
asconst
as well.