nushell/crates/nu-protocol/src
Ian Manske 0918050ac8
Deprecate group in favor of chunks (#13377)
# Description
The name of the `group` command is a little unclear/ambiguous.
Everything I look at it, I think of `group-by`. I think `chunks` more
clearly conveys what the `group` command does. Namely, it divides the
input list into chunks of a certain size. For example,
[`slice::chunks`](https://doc.rust-lang.org/std/primitive.slice.html#method.chunks)
has the same name. So, this PR adds a new `chunks` command to replace
the now deprecated `group` command.

The `chunks` command is a refactored version of `group`. As such, there
is a small performance improvement:
```nushell
# $data is a very large list
> bench { $data | chunks 2 } --rounds 30 | get mean
474ms 921µs 190ns

# deprecation warning was disabled here for fairness
> bench { $data | group 2 } --rounds 30 | get mean
592ms 702µs 440ns



> bench { $data | chunks 200 } --rounds 30 | get mean
374ms 188µs 318ns

> bench { $data | group 200 } --rounds 30 | get mean
481ms 264µs 869ns 



> bench { $data | chunks 1 } --rounds 30 | get mean
642ms 574µs 42ns

> bench { $data | group 1 } --rounds 30 | get mean
981ms 602µs 513ns
```

# User-Facing Changes
- `group` command has been deprecated in favor of new `chunks` command.
- `chunks` errors when given a chunk size of `0` whereas `group` returns
chunks with one element.

# Tests + Formatting
Added tests for `chunks`, since `group` did not have any tests.

# After Submitting
Update book if necessary.
2024-07-16 03:49:00 +00:00
..
ast Document public types in nu-protocol (#12906) 2024-07-11 13:30:12 +02:00
config Document public types in nu-protocol (#12906) 2024-07-11 13:30:12 +02:00
debugger Add IR support to the debugger (#13345) 2024-07-13 01:58:21 -07:00
engine Update config directly at assignment (#13332) 2024-07-11 06:09:33 -07:00
errors Deprecate group in favor of chunks (#13377) 2024-07-16 03:49:00 +00:00
ir Add IR support to the debugger (#13345) 2024-07-13 01:58:21 -07:00
pipeline Deprecate group in favor of chunks (#13377) 2024-07-16 03:49:00 +00:00
plugin remove the deprecated register command (#13297) 2024-07-05 07:16:50 -05:00
process Document public types in nu-protocol (#12906) 2024-07-11 13:30:12 +02:00
value Document public types in nu-protocol (#12906) 2024-07-11 13:30:12 +02:00
alias.rs Document public types in nu-protocol (#12906) 2024-07-11 13:30:12 +02:00
did_you_mean.rs Improve case insensitivity consistency (#10884) 2023-11-08 23:58:54 +01:00
eval_base.rs Update config directly at assignment (#13332) 2024-07-11 06:09:33 -07:00
eval_const.rs Update config directly at assignment (#13332) 2024-07-11 06:09:33 -07:00
example.rs Overhaul the plugin cache file with a new msgpack+brotli format (#12579) 2024-04-21 07:36:26 -05:00
id.rs Internal representation (IR) compiler and evaluator (#13330) 2024-07-10 17:33:59 -07:00
lev_distance.rs Rework for new clippy lints (#12736) 2024-05-02 19:29:03 +02:00
lib.rs Add top-level crate documentation/READMEs (#12907) 2024-07-14 10:10:41 +02:00
module.rs Enable reloading changes to a submodule (#13170) 2024-06-25 18:33:37 -07:00
parser_path.rs Enable reloading changes to a submodule (#13170) 2024-06-25 18:33:37 -07:00
signature.rs Document public types in nu-protocol (#12906) 2024-07-11 13:30:12 +02:00
span.rs Document public types in nu-protocol (#12906) 2024-07-11 13:30:12 +02:00
syntax_shape.rs open, rm, umv, cp, rm and du: Don't globs if inputs are variables or string interpolation (#11886) 2024-02-23 09:17:09 +08:00
ty.rs Deprecate group in favor of chunks (#13377) 2024-07-16 03:49:00 +00:00