Skip to content

Commit dcf398c

Browse files
committed
Updates from review comments
1 parent 22a950a commit dcf398c

File tree

1 file changed

+7
-23
lines changed

1 file changed

+7
-23
lines changed

book/standard_library.md

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ While working at the commandline, it can be convenient to load the entire standa
4040
use std *
4141
```
4242

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.
4444

4545
::: important Optimal Startup when Using the Standard Library
4646
See the [notes below](#optimal-startup) on how to ensure that your configuration isn't loading the entire Standard Library.
4747
:::
4848

4949
### Importing Submodules
5050

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._
5252

5353
There are several forms that can be used:
5454

@@ -93,9 +93,9 @@ Submodules that are normally imported with `use std/<submodule>`:
9393
- `use std/log`: The `log <subcommands>` such as `log warning <msg>`
9494
- `use std/math`: Mathematical constants such as `$math.E`. These can also be imported without a prefix using Form #2 below.
9595

96-
#### 2. Import all submodule commands without a prefix
96+
#### 2. Import the _contents_ of the module directly
9797

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:
9999

100100
```nu
101101
use std/formats *
@@ -117,7 +117,7 @@ As with most modules, you can choose to import only a subset of the commands. Fo
117117
use std/iter [ zip-with ]
118118
```
119119

120-
#### 4. Not Recommended - `use std <submodule>` and `use std <submodule> *`
120+
#### 4. `use std <submodule>`
121121

122122
While it is _possible_ to import Standard Library submodules using a space-separated form:
123123

@@ -126,29 +126,13 @@ use std log
126126
use std formats *
127127
```
128128

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):
137-
138-
```nu
139-
bench -n 200 --pretty { nu -c "use std/formats *; exit" }
140-
# => 9ms 271µs 832ns +/- 328µs 860ns
141-
bench -n 200 --pretty { nu -c "use std formats *; exit" }
142-
# => 26ms 921µs 59ns +/- 588µs 919ns
143-
```
144-
145-
:::
129+
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.
146130

147131
## The Standard Library Candidate Module
148132

149133
(Also known as `std-rfc`)
150134

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.
152136

153137
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.
154138

0 commit comments

Comments
 (0)