Skip to content

__optimize_range__

builtin · libnexusinterp/nexus-value/ov-proprietary.cc

: val = __optimize_range__ ()
: old_val = __optimize_range__ (new_val)
: old_val = __optimize_range__ (new_val, "local")

Read or change whether ranges are kept in a compact internal form.

With no argument the current setting is returned; supplying new_val changes it and returns the previous value. While the setting is on—its default—a value produced by the colon notation (as in 1:13) is held as a range, storing only its base, increment, and limit instead of every element, which saves both memory and work. Turning it off forces such values to be expanded into ordinary full matrices.

Invoked inside a function with a trailing "local" argument, the new setting applies only to that function and anything it calls, and the previous setting is restored automatically when the function returns.