Skip to content
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

Make $nu constant #10160

Merged
merged 4 commits into from Sep 1, 2023
Merged

Make $nu constant #10160

merged 4 commits into from Sep 1, 2023

Conversation

kubouch
Copy link
Contributor

@kubouch kubouch commented Aug 30, 2023

Description

This PR makes $nu a parse-time constant. The benefits are two-fold:

  1. $nu is now usable in more situations. For example, reloading the config file is now more convenient than ever:
source $nu.config-path
  1. Performance. Evaluating $nu is now approximately 15x faster:
> use std
> std bench { 1..1000 | each { $nu } } --pretty
# before:
80ms 681µs 622ns +/- 1ms 185µs 491ns
# after:
5ms 211µs 764ns +/- 1ms 39µs 16ns

The only remaining question is where to move the eval_nu_variable() since it is now not a part of the engine. I'm leaning towards nu-protocol which would move the sysinfo dependency from nu-engine to nu-protocol, alongside to introducing nu-path dependency.

User-Facing Changes

Enhances $nu usability, but everything should work exactly as before.

Tests + Formatting

After Submitting

This adds nu-path and sysinfo dependencies to nu-protocol, but removes
sysinfo from nu-engine.
@kubouch kubouch marked this pull request as ready for review August 31, 2023 19:31
@sophiajt
Copy link
Member

sophiajt commented Sep 1, 2023

Let's do it

@kubouch kubouch merged commit f35808c into nushell:main Sep 1, 2023
20 checks passed
@kubouch kubouch deleted the const-nu branch September 1, 2023 06:20
@fdncred fdncred added the pr:release-note-mention Addition/Improvement to be mentioned in the release notes label Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:release-note-mention Addition/Improvement to be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants