You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: book/standard_library.md
+7-23Lines changed: 7 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,15 +40,15 @@ While working at the commandline, it can be convenient to load the entire standa
40
40
use std *
41
41
```
42
42
43
-
However, this form should be avoided in custom commands and scripts since it has the longest load time. While the load time is only on the order of ~20-30 milliseconds on an average system, that can add up in certain scenarios.
43
+
However, this form should be avoided in custom commands and scripts since it has the longest load time.
44
44
45
45
::: important Optimal Startup when Using the Standard Library
46
46
See the [notes below](#optimal-startup) on how to ensure that your configuration isn't loading the entire Standard Library.
47
47
:::
48
48
49
49
### Importing Submodules
50
50
51
-
Each submodule of the standard library can be loaded separately. Again, for best performance, load only the submodule(s) that you need in your code.
51
+
Each submodule of the standard library can be loaded separately. Again, _for best performance, load only the submodule(s) that you need in your code._
52
52
53
53
There are several forms that can be used:
54
54
@@ -93,9 +93,9 @@ Submodules that are normally imported with `use std/<submodule>`:
93
93
-`use std/log`: The `log <subcommands>` such as `log warning <msg>`
94
94
-`use std/math`: Mathematical constants such as `$math.E`. These can also be imported without a prefix using Form #2 below.
95
95
96
-
#### 2. Import all submodule commands without a prefix
96
+
#### 2. Import the _contents_ of the module directly
97
97
98
-
For certain submodules, you will want the commands from a submodule to be available in the current namespace, so that you _can_ simply access the command by name. For instance:
98
+
For certain submodules, you will want the commands from a submodule to be available in the current scope, so that you _can_ simply access the command by name. For instance:
99
99
100
100
```nu
101
101
use std/formats *
@@ -117,7 +117,7 @@ As with most modules, you can choose to import only a subset of the commands. Fo
117
117
use std/iter [ zip-with ]
118
118
```
119
119
120
-
#### 4. Not Recommended - `use std <submodule>` and `use std <submodule> *`
120
+
#### 4. `use std <submodule>`
121
121
122
122
While it is _possible_ to import Standard Library submodules using a space-separated form:
123
123
@@ -126,29 +126,13 @@ use std log
126
126
use std formats *
127
127
```
128
128
129
-
This is NOT RECOMMENDED. Using this form has the same performance impact as:
130
-
131
-
```nu
132
-
use std *
133
-
```
134
-
135
-
::: caution
136
-
The difference is subtle, but important from a performance perspective. Using `std/<submodules>` (with a slash) is far faster than `std <submodule>` (with a space):
However, similar to `use std *`, this form first loads the _entire_ Standard Library into scope and _then_ imports the submodules. In contrast, using the slash-separated version _only_ imports the submodule and will be much faster as a result.
146
130
147
131
## The Standard Library Candidate Module
148
132
149
133
(Also known as `std-rfc`)
150
134
151
-
`stdlib-candidate`, found in the [nu_scripts Repository](https://github.com/nushell/nu_scripts/tree/main/stdlib-candidate/std-rfc), serves as a staging ground for new commands before they are added to the Standard Library.
135
+
`stdlib-candidate`, found in the [nu_scripts Repository](https://github.com/nushell/nu_scripts/tree/main/stdlib-candidate/std-rfc), serves as a staging ground for possible Standard Library additions.
152
136
153
137
If you are interested in adding to the Standard Library, please submit your code via PR to the Candidate module in that repository. We also encourage you to install this module and provide feedback on upcoming candidate commands.
0 commit comments